def selectAction(self): edged = [ objex for objex in FreeCADGui.Selection.getSelectionEx() if frameCmd.edges([objex]) ] if edged: self.Axis = frameCmd.edges([edged[0]])[0] self.deleteArrow() from polarUtilsCmd import arrow where = FreeCAD.Placement() where.Base = self.Axis.valueAt(self.Axis.LastParameter) where.Rotation = FreeCAD.Rotation( FreeCAD.Vector(0, 0, 1), self.Axis.tangentAt(self.Axis.LastParameter)) size = [ self.Axis.Length / 20.0, self.Axis.Length / 10.0, self.Axis.Length / 20.0 ] self.arrow = arrow(pl=where, scale=size, offset=self.Axis.Length / 10.0) if self.Axis.curvatureAt(0): O = self.Axis.centerOfCurvatureAt(0) n = self.Axis.tangentAt(0).cross(self.Axis.normalAt(0)) from Part import Edge, Line self.Axis = (Edge( Line(FreeCAD.Vector(O), FreeCAD.Vector(O + n)))) self.form.lab1.setText(edged[0].Object.Label + ": edge")
def selectAction(self): edged = [ objex for objex in FreeCADGui.Selection.getSelectionEx() if fCmd.edges([objex]) ] if edged: self.Axis = fCmd.edges([edged[0]])[0] self.deleteArrow() from uCmd import arrow where = FreeCAD.Placement() where.Base = self.Axis.valueAt(self.Axis.LastParameter) where.Rotation = FreeCAD.Rotation( FreeCAD.Vector(0, 0, 1), self.Axis.tangentAt(self.Axis.LastParameter)) obj = edged[ 0].Object #TARGET [solved]: make "where" deal with App::Parts if fCmd.isPartOfPart(obj): part = fCmd.isPartOfPart(obj) where = part.Placement.multiply(where) size = [ self.Axis.Length / 20.0, self.Axis.Length / 10.0, self.Axis.Length / 20.0 ] self.arrow = arrow(pl=where, scale=size, offset=self.Axis.Length / 10.0) if self.Axis.curvatureAt(0): O = self.Axis.centerOfCurvatureAt(0) n = self.Axis.tangentAt(0).cross(self.Axis.normalAt(0)) from Part import Edge, Line self.Axis = (Edge( Line(FreeCAD.Vector(O), FreeCAD.Vector(O + n)))) self.form.lab1.setText(edged[0].Object.Label + ": edge")
def getPrincipalAx(self, ax='Z'): self.deleteArrow() from Part import Edge, Line O = FreeCAD.Vector() l = Line(O, FreeCAD.Vector(0, 0, 1000)) if ax == 'X': l = Line(O, FreeCAD.Vector(1000, 0, 0)) elif ax == 'Y': l = Line(O, FreeCAD.Vector(0, 1000, 0)) self.Axis = Edge(l) self.form.lab1.setText("Principal: " + ax)