single Placement: new feature - Euler angles
This commit is contained in:
parent
919e9e6be3
commit
0989ae00d8
|
@ -98,7 +98,7 @@ class LatticePlacementAx(lattice2BaseFeature.LatticeFeature):
|
|||
"The Lattice Placement object, defined by axes directions"
|
||||
|
||||
def derivedInit(self,obj):
|
||||
self.Type = "LatticePlacement"
|
||||
self.Type = "LatticePlacementAx"
|
||||
|
||||
obj.addProperty("App::PropertyEnumeration","Priority","Lattice Placement","Example: ZXY = ZDir followed strictly, XDir is a hint, YDir is ignored and computed from others.")
|
||||
obj.Priority = ["XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"]
|
||||
|
@ -136,6 +136,35 @@ class LatticePlacementAx(lattice2BaseFeature.LatticeFeature):
|
|||
|
||||
return [plm]
|
||||
|
||||
def makeLatticePlacementEuler(name):
|
||||
'''makePlacement(name): makes a Placement object.'''
|
||||
return lattice2BaseFeature.makeLatticeFeature(name, LatticePlacementEuler, ViewProviderLatticePlacement)
|
||||
|
||||
class LatticePlacementEuler(lattice2BaseFeature.LatticeFeature):
|
||||
"The Lattice Placement object, defined by axes directions"
|
||||
|
||||
def derivedInit(self,obj):
|
||||
self.Type = "LatticePlacementEuler"
|
||||
|
||||
obj.addProperty("App::PropertyAngle","Yaw","Lattice Placement","Rotation around Z axis")
|
||||
obj.addProperty("App::PropertyAngle","Pitch","Lattice Placement","Rotation around Y axis")
|
||||
obj.addProperty("App::PropertyAngle","Roll","Lattice Placement","Rotation around X axis")
|
||||
|
||||
obj.ExposePlacement = True
|
||||
|
||||
def derivedExecute(self,obj):
|
||||
old_pos = App.Vector()
|
||||
try:
|
||||
old_pos = lattice2BaseFeature.getPlacementsList(obj, suppressWarning= True)[0].Base
|
||||
except Exception:
|
||||
pass #retrieving position may fail if the object is recomputed for the very first time
|
||||
|
||||
ori = App.Rotation(obj.Yaw, obj.Pitch, obj.Roll)
|
||||
|
||||
plm = App.Placement(old_pos, ori)
|
||||
|
||||
return [plm]
|
||||
|
||||
class ViewProviderLatticePlacement(lattice2BaseFeature.ViewProviderLatticeFeature):
|
||||
|
||||
def getIcon(self):
|
||||
|
@ -178,6 +207,17 @@ def CreateLatticePlacementAx(label, priority, XDir, YDir, ZDir):
|
|||
FreeCADGui.doCommand("f = None")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
def CreateLatticePlacementEuler(name):
|
||||
sel = FreeCADGui.Selection.getSelectionEx()
|
||||
FreeCAD.ActiveDocument.openTransaction("Create Lattice Placement")
|
||||
FreeCADGui.addModule("lattice2Placement")
|
||||
FreeCADGui.addModule("lattice2Executer")
|
||||
FreeCADGui.doCommand("f = lattice2Placement.makeLatticePlacementEuler(name='"+name+"')")
|
||||
FreeCADGui.doCommand("lattice2Executer.executeFeature(f)")
|
||||
FreeCADGui.doCommand("Gui.Selection.addSelection(f)")
|
||||
FreeCADGui.doCommand("f = None")
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
|
||||
class _CommandPlacement:
|
||||
"Command to create Lattice Placement feature"
|
||||
|
@ -249,6 +289,32 @@ cmdName = "Lattice2_PlacementAx_AlongZ"
|
|||
FreeCADGui.addCommand(cmdName, _CommandPlacementAx("along Z","Single Placement with local X aligned along global Z","Plm along Z","XZY", XDir= App.Vector(0,0,1)))
|
||||
_listOfSubCommands.append(cmdName)
|
||||
|
||||
class _CommandPlacementEuler:
|
||||
"Command to create Lattice Placement feature"
|
||||
|
||||
def GetResources(self):
|
||||
return {'Pixmap' : getIconPath("Lattice2_Placement_New.svg"),
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Lattice2_Placement","Single Placement: Euler angles"),
|
||||
'Accel': "",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Lattice2_Placement","Lattice Placement: driven by Euler angles (yaw, pitch, roll)")}
|
||||
|
||||
def Activated(self):
|
||||
try:
|
||||
CreateLatticePlacementEuler(name= "PlacementEu")
|
||||
except Exception as err:
|
||||
msgError(err)
|
||||
|
||||
def IsActive(self):
|
||||
if FreeCAD.ActiveDocument:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
cmdName = "Lattice2_PlacementEuler"
|
||||
FreeCADGui.addCommand(cmdName, _CommandPlacementEuler())
|
||||
_listOfSubCommands.append(cmdName)
|
||||
|
||||
|
||||
import lattice2ArrayFromShape
|
||||
_listOfSubCommands.append('Lattice2_PlacementFromShape')
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user