def RunOrTest(self, b_run): if Gui.ActiveDocument: in_edit = Gui.ActiveDocument.getInEdit() if in_edit is not None: raise CommandError( self, u"{object} is currently being edited. Can't enter anything." .format(object=in_edit.Object.Label)) sel = Gui.Selection.getSelection() if len(sel) == 0: raise CommandError( self, "Enter Object command. Please select an object to enter, first. It can be a container, or a sketch." ) elif len(sel) == 1: sel = screen(sel[0]) ac = Containers.activeContainer() if Containers.isContainer(sel): if sel in Containers.getContainerChain(ac) + [ac]: raise CommandError(self, "Already inside this object") if b_run: Containers.setActiveContainer(sel) if b_run: Gui.Selection.clearSelection() else: cnt = Containers.getContainer(sel) if ac is cnt: if b_run: Gui.ActiveDocument.setEdit(sel) else: if b_run: Containers.setActiveContainer(cnt) else: raise CommandError( self, u"Enter Object 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): if Gui.ActiveDocument.getInEdit() is not None: if b_run: Gui.ActiveDocument.resetEdit() App.ActiveDocument.recompute() App.ActiveDocument.commitTransaction() elif Gui.Control.activeDialog(): if b_run: Gui.Control.closeDialog() App.ActiveDocument.recompute() App.ActiveDocument.commitTransaction() else: ac = Containers.activeContainer() if ac.isDerivedFrom("App::Document"): raise CommandError(self, "Nothing to leave.") if b_run: Containers.setActiveContainer(Containers.getContainer(ac)) if b_run: Gui.Selection.clearSelection() if b_run: Gui.Selection.addSelection(ac) if b_run: App.ActiveDocument.recompute() #fixme: scoped recompute, maybe?
def RunOrTest(self, b_run): if Gui.ActiveDocument.getInEdit() is not None: if b_run: Gui.ActiveDocument.resetEdit() App.ActiveDocument.recompute() App.ActiveDocument.commitTransaction() elif Gui.Control.activeDialog(): if b_run: Gui.Control.closeDialog() App.ActiveDocument.recompute() App.ActiveDocument.commitTransaction() else: ac = Containers.activeContainer() if ac.isDerivedFrom("App::Document"): raise CommandError(self, "Nothing to leave.") if b_run: Containers.setActiveContainer(Containers.getContainer(ac)) if b_run: Gui.Selection.clearSelection() if b_run: Gui.Selection.addSelection(ac) if b_run: App.ActiveDocument.recompute() #fixme: scoped recompute, maybe?
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): if Gui.ActiveDocument: in_edit = Gui.ActiveDocument.getInEdit() if in_edit is not None: raise CommandError(self, u"{object} is currently being edited. Can't enter anything.".format(object= in_edit.Object.Label)) sel = Gui.Selection.getSelection() if len(sel)==0 : raise CommandError(self, "Enter Object command. Please select an object to enter, first. It can be a container, or a sketch.") elif len(sel)==1: sel = screen(sel[0]) ac = Containers.activeContainer() if Containers.isContainer(sel): if sel in Containers.getContainerChain(ac) + [ac]: raise CommandError(self, "Already inside this object") if b_run: Containers.setActiveContainer(sel) if b_run: Gui.Selection.clearSelection() else: cnt = Containers.getContainer(sel) if ac is cnt: if b_run: Gui.ActiveDocument.setEdit(sel) else: if b_run: Containers.setActiveContainer(cnt) else: raise CommandError(self, u"Enter Object command. You need to select exactly one object (you selected {num}).".format(num= len(sel)))
def doubleClicked(self, vobj): Containers.setActiveContainer(Containers.getContainer( vobj.Object.Base)) return True