def execute(self): input_shape = self.input.shape topo = Topo(input_shape) self._n_edges = topo.number_of_edges() builder = BRepFilletAPI.BRepFilletAPI_MakeChamfer(input_shape) Map = TDF.TDF_LabelMap() itr = TDF.TDF_ChildIterator(self.parent_label, True) while itr.More(): sub_label = itr.Value() Map.Add(sub_label) itr.Next() selector = self.selector ret = selector.Solve(Map) if not ret: raise Exception("Failed to solve for edge") #print "Failed to solve for edge" nt = TNaming.TNaming_Tool() selected_shape = nt.CurrentShape(selector.NamedShape()) selected_edge = TopoDS.TopoDS().Edge(selected_shape) try: face = Topo(input_shape).faces_from_edge(selected_edge).next() except RuntimeError: raise #not sure how to handle this size = self.size builder.Add(size, size, selected_edge, face) self.update_naming(builder) return builder.Shape()
ns_builder = TNaming.TNaming_Builder(box_label) ns_builder.Generated(box2) h_a = TNaming.Handle_TNaming_NamedShape() ns_id = TNaming.TNaming_NamedShape().ID() for i, edge in enumerate(Topo(box2).edges()): sub_label = box_label.FindChild(i + 1) ns_builder = TNaming.TNaming_Builder(sub_label) ns_builder.Generated(edge) # #Need to build a map covering all the OCAF nodes which might #contain relevent shapes # aMap = TDF.TDF_LabelMap() aMap.Add(box_label) itr = TDF.TDF_ChildIterator(box_label, True) while itr.More(): sub_label = itr.Value() aMap.Add(sub_label) itr.Next() # #Solve for the selected edge # ok = selector.Solve(aMap) print "solve OK", ok # #Extract the selected edge