def proceed(self): """Proceed with the command if one object was selected.""" if self.call: self.view.removeEventCallback("SoEvent", self.call) self.sel = Gui.Selection.getSelection()[0] if not self.sel.isDerivedFrom("Part::Feature"): _wrn(translate("draft", "Cannot offset this object type")) self.finish() else: self.step = 0 self.dvec = None self.npts = None self.constrainSeg = None self.ui.offsetUi() occmode = utils.param.GetBool("Offset_OCC", False) self.ui.occOffset.setChecked(occmode) self.linetrack = trackers.lineTracker() self.faces = False self.shape = self.sel.Shape self.mode = None if utils.getType(self.sel) in ("Circle", "Arc"): self.ghost = trackers.arcTracker() self.mode = "Circle" self.center = self.shape.Edges[0].Curve.Center self.ghost.setCenter(self.center) self.ghost.setStartAngle(math.radians(self.sel.FirstAngle)) self.ghost.setEndAngle(math.radians(self.sel.LastAngle)) elif utils.getType(self.sel) == "BSpline": self.ghost = trackers.bsplineTracker(points=self.sel.Points) self.mode = "BSpline" elif utils.getType(self.sel) == "BezCurve": _wrn( translate( "draft", "Offset of Bezier curves " "is currently not supported")) self.finish() return else: if len(self.sel.Shape.Edges) == 1: import Part if isinstance(self.sel.Shape.Edges[0].Curve, Part.Circle): self.ghost = trackers.arcTracker() self.mode = "Circle" self.center = self.shape.Edges[0].Curve.Center self.ghost.setCenter(self.center) if len(self.sel.Shape.Vertexes) > 1: _edge = self.sel.Shape.Edges[0] self.ghost.setStartAngle(_edge.FirstParameter) self.ghost.setEndAngle(_edge.LastParameter) if not self.ghost: self.ghost = trackers.wireTracker(self.shape) self.mode = "Wire" self.call = self.view.addEventCallback("SoEvent", self.action) _msg(translate("draft", "Pick distance")) if self.planetrack: self.planetrack.set(self.shape.Vertexes[0].Point) self.running = True
def initGhost(self, obj): """Initialize preview ghost.""" if utils.get_type(obj) == "Wire": return trackers.wireTracker(obj.Shape) elif utils.get_type(obj) == "BSpline": return trackers.bsplineTracker() elif utils.get_type(obj) == "BezCurve": return trackers.bezcurveTracker() elif utils.get_type(obj) == "Circle": return trackers.arcTracker()
def init_preview_object(self, obj): return trackers.wireTracker(obj.Shape)