def slotStartEditing(self, feature): print(u"Start Editing {f}".format(f=feature.Name)) cnt = GT.getContainer(feature) if GT.activeContainer() is not cnt: print( u"Feature being edited is not in active container. Activating {cnt}..." .format(cnt=cnt.Name)) Gui.ActiveDocument.resetEdit() GT.setActiveContainer(cnt) return if feature.isDerivedFrom("PartDesign::Boolean"): # show all bodies nearby... part = GT.getContainer(cnt) children = GT.getDirectChildren(part) children = [ child for child in children if child.isDerivedFrom("Part::BodyBase") ] children = set(children) children.remove(cnt) for obj in GT.getAllDependent(cnt): if obj in children: children.remove(obj) tv = TempoVis(feature.Document) tv.show(children) self.edit_TVs[feature.Document.Name] = tv
def RunOrTest(self, b_run): sel = Gui.Selection.getSelection() if len(sel) == 0: raise CommandError( self, "Make Ghost command. Please select an object to import to active container, first. The object must be geometry." ) elif len(sel) == 1: sel = sel[0] ac = Containers.activeContainer() if sel in Containers.getDirectChildren(ac): raise CommandError( self, u"{feat} is from active container ({cnt}). Please select an object belonging to another container." .format(feat=sel.Label, cnt=ac.Label)) if sel in (Containers.getAllDependent(ac) + [ac]): raise CommandError( self, "Can't create a ghost here, because a circular dependency will result." ) if b_run: CreateGhost('Ghost', sel) else: raise CommandError( self, u"Make Ghost command. You need to select exactly one object (you selected {num})." .format(num=len(sel)))
def check_dag(self): """check_dag(): returns True if DAG-compatible, and False otherwise. Note that it may be wrong for mass-replacements""" if replaced: raise AlreadyReplacedError("Replacement already done, can't check.") if self.new_object is None: return True import Containers deps = Containers.getAllDependent(self.relation.linking_object) if self.new_object in deps: return False return True
def check_dag(self): """check_dag(): returns True if DAG-compatible, and False otherwise. Note that it may be wrong for mass-replacements""" if replaced: raise AlreadyReplacedError( "Replacement already done, can't check.") if self.new_object is None: return True import Containers deps = Containers.getAllDependent(self.relation.linking_object) if self.new_object in deps: return False return True
def RunOrTest(self, b_run): sel = Gui.Selection.getSelection() if len(sel)==0 : raise CommandError(self, "MUX Assembly command. Please select a Part container, then invoke the tool. A mux object will be created, a compound of all features of Part.") elif len(sel)==1: sel = sel[0] ac = Containers.activeContainer() if b_run: if sel in (Containers.getAllDependent(ac)+ [ac]): raise CommandError(self, "Can't create MUX here, because a circular dependency will result.") Create(sel) else: raise CommandError(self, u"MUX Assembly command. You need to select exactly one object (you selected {num}).".format(num= len(sel)))
def RunOrTest(self, b_run): sel = Gui.Selection.getSelection() if len(sel)==0 : raise CommandError(self, "Shapebinder command. Please select an object to import to active container, first. The object must be geometry.") elif len(sel)==1: sel = screen(sel[0]) ac = Containers.activeContainer() if sel in Containers.getDirectChildren(ac): raise CommandError(self, u"{feat} is from active container ({cnt}). Please select an object belonging to another container.".format(feat= sel.Label, cnt= ac.Label)) if sel in (Containers.getAllDependent(ac)+ [ac]): raise CommandError(self, "Can't create a shapebinder, because a circular dependency will result.") if b_run: CreateShapeBinder(sel) else: raise CommandError(self, u"Shapebinder command. You need to select exactly one object (you selected {num}).".format(num= len(sel)))
def slotStartEditing(self, feature): print(u"Start Editing {f}".format(f= feature.Name)) cnt = GT.getContainer(feature) if GT.activeContainer() is not cnt: print(u"Feature being edited is not in active container. Activating {cnt}...".format(cnt= cnt.Name)) Gui.ActiveDocument.resetEdit() GT.setActiveContainer(cnt) return if feature.isDerivedFrom("PartDesign::Boolean"): # show all bodies nearby... part = GT.getContainer(cnt) children = GT.getDirectChildren(part) children = [child for child in children if child.isDerivedFrom("Part::BodyBase")] children = set(children) children.remove(cnt) for obj in GT.getAllDependent(cnt): if obj in children: children.remove(obj) tv = TempoVis(feature.Document) tv.show(children) self.edit_TVs[feature.Document.Name] = tv
def RunOrTest(self, b_run): sel = Gui.Selection.getSelection() if len(sel) == 0: raise CommandError( self, "MUX Assembly command. Please select a Part container, then invoke the tool. A mux object will be created, a compound of all features of Part." ) elif len(sel) == 1: sel = sel[0] ac = Containers.activeContainer() if b_run: if sel in (Containers.getAllDependent(ac) + [ac]): raise CommandError( self, "Can't create MUX here, because a circular dependency will result." ) Create(sel) else: raise CommandError( self, u"MUX Assembly command. You need to select exactly one object (you selected {num})." .format(num=len(sel)))