def set_subelement_ghosts(self): """Set ghost for the subelements (vertices, edges).""" import Part for obj in self.selected_subelements: for subelement in obj.SubObjects: if (isinstance(subelement, Part.Vertex) or isinstance(subelement, Part.Edge)): self.ghosts.append(trackers.ghostTracker(subelement))
def get_subelement_ghosts(self): """Get ghost for the subelements (vertices, edges).""" import Part ghosts = [] for object in self.selected_subelements: for subelement in object.SubObjects: if isinstance(subelement, (Part.Vertex, Part.Edge)): ghosts.append(trackers.ghostTracker(subelement)) return ghosts
def set_ghosts(self): """Set the ghost to display.""" for ghost in self.ghosts: ghost.remove() if self.ui.isSubelementMode.isChecked(): self.ghosts = self.get_subelement_ghosts() else: self.ghosts = [trackers.ghostTracker(self.selected_objects)] if self.center: for ghost in self.ghosts: ghost.center(self.center)
def set_ghosts(self): """Set the previews of the objects to scale.""" if self.ui.isSubelementMode.isChecked(): return self.set_subelement_ghosts() self.ghosts = [trackers.ghostTracker(self.selected_objects)]
def set_ghosts(self): """Set the ghost to display.""" if self.ui.isSubelementMode.isChecked(): return self.set_subelement_ghosts() self.ghosts = [trackers.ghostTracker(self.selected_objects)]
def proceed(self): """Proceed with execution of the command after proper selection.""" if self.call: self.view.removeEventCallback("SoEvent", self.call) sel = Gui.Selection.getSelection() if len(sel) == 2: self.trimObjects(sel) self.finish() return self.obj = sel[0] self.ui.trimUi() self.linetrack = trackers.lineTracker() import DraftGeomUtils import Part if "Shape" not in self.obj.PropertiesList: return if "Placement" in self.obj.PropertiesList: self.placement = self.obj.Placement if len(self.obj.Shape.Faces) == 1: # simple extrude mode, the object itself is extruded self.extrudeMode = True self.ghost = [trackers.ghostTracker([self.obj])] self.normal = self.obj.Shape.Faces[0].normalAt(0.5, 0.5) for v in self.obj.Shape.Vertexes: self.ghost.append(trackers.lineTracker()) elif len(self.obj.Shape.Faces) > 1: # face extrude mode, a new object is created ss = Gui.Selection.getSelectionEx()[0] if len(ss.SubObjects) == 1: if ss.SubObjects[0].ShapeType == "Face": self.obj = self.doc.addObject("Part::Feature", "Face") self.obj.Shape = ss.SubObjects[0] self.extrudeMode = True self.ghost = [trackers.ghostTracker([self.obj])] self.normal = self.obj.Shape.Faces[0].normalAt(0.5, 0.5) for v in self.obj.Shape.Vertexes: self.ghost.append(trackers.lineTracker()) else: # normal wire trimex mode self.color = self.obj.ViewObject.LineColor self.width = self.obj.ViewObject.LineWidth # self.obj.ViewObject.Visibility = False self.obj.ViewObject.LineColor = (0.5, 0.5, 0.5) self.obj.ViewObject.LineWidth = 1 self.extrudeMode = False if self.obj.Shape.Wires: self.edges = self.obj.Shape.Wires[0].Edges self.edges = Part.__sortEdges__(self.edges) else: self.edges = self.obj.Shape.Edges self.ghost = [] lc = self.color sc = (lc[0], lc[1], lc[2]) sw = self.width for e in self.edges: if DraftGeomUtils.geomType(e) == "Line": self.ghost.append( trackers.lineTracker(scolor=sc, swidth=sw)) else: self.ghost.append(trackers.arcTracker(scolor=sc, swidth=sw)) if not self.ghost: self.finish() for g in self.ghost: g.on() self.activePoint = 0 self.nodes = [] self.shift = False self.alt = False self.force = None self.cv = None self.call = self.view.addEventCallback("SoEvent", self.action) _msg(translate("draft", "Pick distance"))