def update_naming(self, make_shape): label = self.label shape = make_shape.Shape() input_shape = make_shape.Shape1() tool_shape = make_shape.Shape2() builder = TNaming.TNaming_Builder(label) builder.Generated(input_shape, shape) builder.Generated(tool_shape, shape) gen_label = label.FindChild(1) mod_label = label.FindChild(2) del_label = label.FindChild(3) gen_builder = TNaming.TNaming_Builder(gen_label) mod_builder = TNaming.TNaming_Builder(mod_label) del_builder = TNaming.TNaming_Builder(del_label) if make_shape.HasGenerated(): for in_shape in [input_shape, tool_shape]: for face in Topo(in_shape).faces(): gen_shapes = make_shape.Generated(face) itr = TopTools.TopTools_ListIteratorOfListOfShape( gen_shapes) while itr.More(): this = itr.Value() gen_builder.Generated(face, this) print "generated", face, this itr.Next() if make_shape.HasModified(): for face in Topo(input_shape).faces(): mod_shapes = make_shape.Modified(face) itr = TopTools.TopTools_ListIteratorOfListOfShape(mod_shapes) while itr.More(): this = itr.Value() mod_builder.Modify(face, this) print "modified", face, this itr.Next() for face in Topo(tool_shape).faces(): mod_shapes = make_shape.Modified2(face) itr = TopTools.TopTools_ListIteratorOfListOfShape(mod_shapes) while itr.More(): this = itr.Value() mod_builder.Modify(face, this) print "modified2", face, this itr.Next() if make_shape.HasDeleted(): for face in Topo(input_shape).faces(): if make_shape.IsDeleted(face): del_builder.Delete(face) for face in Topo(tool_shape).faces(): if make_shape.IsDeleted(face): del_builder.Delete(face)
def update_naming(self, make_shape): """ Create named shapes for the created primitive and all the sub-shapes we want to track. It seems sufficient to track faces. TNaming_Selector automatically identifies other topology (edges, vertices) based on the faces to which they belong """ label = self.label shape = make_shape.Shape() builder = TNaming.TNaming_Builder(label) builder.Generated(shape) for i, face in enumerate(Topo(shape).faces()): f_label = label.FindChild(i+1) #creates a new label if it is not found builder = TNaming.TNaming_Builder(f_label) builder.Generated(face)
def update_naming(self, make_shape): label = self.label shape = make_shape.Shape() input_shape = make_shape.Shape() builder = TNaming.TNaming_Builder(label) builder.Generated(input_shape, shape) #FindChild creates a new label, if one doesn't exist. #Label entry numbers are not necessarily incremental. #They are more like dictionary keys. gen_label = label.FindChild(1) mod_label = label.FindChild(2) del_label = label.FindChild(3) gen_builder = TNaming.TNaming_Builder(gen_label) mod_builder = TNaming.TNaming_Builder(mod_label) del_builder = TNaming.TNaming_Builder(del_label) topo = Topo(input_shape) for face in topo.faces(): gen_shapes = make_shape.Generated(face) itr = TopTools.TopTools_ListIteratorOfListOfShape(gen_shapes) while itr.More(): this = itr.Value() gen_builder.Generated(face, this) print "generated", face, this itr.Next() for face in topo.faces(): mod_shapes = make_shape.Modified(face) itr = TopTools.TopTools_ListIteratorOfListOfShape(mod_shapes) while itr.More(): this = itr.Value() mod_builder.Modified(face, this) print "modified", face, this itr.Next() for face in topo.faces(): if make_shape.IsDeleted(face): del_builder.Delete(face)
app = AppStd.AppStd_Application() h_doc = TDocStd.Handle_TDocStd_Document() schema = TCollection.TCollection_ExtendedString("MyFormat") app.NewDocument(schema, h_doc) doc = h_doc.GetObject() root = doc.Main() ts = TDF.TDF_TagSource() box = BRepPrimAPI.BRepPrimAPI_MakeBox(20.0, 20.0, 20.0).Shape() box_label = ts.NewChild(root) ns_builder = TNaming.TNaming_Builder(box_label) ns_builder.Generated(box) topo = Topo(box) ## ##Name all the subshape we *might* want to refer to later ## for edge in topo.edges(): sub_label = ts.NewChild(box_label) ns_builder = TNaming.TNaming_Builder(sub_label) ns_builder.Generated(edge) # #Find and Name an edge #