PartDesign: Placements land to active body
This commit is contained in:
parent
9f302010d1
commit
bc83566a3d
|
@ -36,16 +36,22 @@ import lattice2Subsequencer as Subsequencer
|
||||||
|
|
||||||
def makeAttachablePlacement(name):
|
def makeAttachablePlacement(name):
|
||||||
'''makeAttachablePlacement(name): makes an attachable Placement object.'''
|
'''makeAttachablePlacement(name): makes an attachable Placement object.'''
|
||||||
rev_number = int(App.Version()[2].split(" ")[0])
|
|
||||||
|
try:
|
||||||
|
rev_number = int(App.Version()[2].split(" ")[0])
|
||||||
|
except Exception as err:
|
||||||
|
rev_number = 10000000
|
||||||
|
|
||||||
if rev_number < 9177:
|
if rev_number < 9177:
|
||||||
#obsolete!
|
#obsolete!
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::AttachableObjectPython",name)
|
obj = FreeCAD.ActiveDocument.addObject("Part::AttachableObjectPython",name)
|
||||||
|
AttachablePlacement(obj)
|
||||||
|
if FreeCAD.GuiUp:
|
||||||
|
ViewProviderAttachablePlacement(obj.ViewObject)
|
||||||
else:
|
else:
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
obj = lattice2BaseFeature.makeLatticeFeature(name, AttachablePlacement, ViewProviderAttachablePlacement, no_disable_attacher= True)
|
||||||
obj.addExtension("Part::AttachExtensionPython", None)
|
obj.addExtension("Part::AttachExtensionPython", None)
|
||||||
AttachablePlacement(obj)
|
|
||||||
if FreeCAD.GuiUp:
|
|
||||||
ViewProviderAttachablePlacement(obj.ViewObject)
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
class AttachablePlacement(lattice2BaseFeature.LatticeFeature):
|
class AttachablePlacement(lattice2BaseFeature.LatticeFeature):
|
||||||
|
|
|
@ -49,16 +49,34 @@ def getDefShapeColor():
|
||||||
return (r/255.0, g/255.0, b/255.0, (255-o)/255.0)
|
return (r/255.0, g/255.0, b/255.0, (255-o)/255.0)
|
||||||
|
|
||||||
|
|
||||||
def makeLatticeFeature(name, AppClass, ViewClass):
|
def makeLatticeFeature(name, AppClass, ViewClass, no_body = False, no_disable_attacher = False):
|
||||||
'''makeLatticeFeature(name, AppClass, ViewClass = None): makes a document object for a LatticeFeature-derived object.'''
|
'''makeLatticeFeature(name, AppClass, ViewClass, no_body = False): makes a document object for a LatticeFeature-derived object.
|
||||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
|
||||||
|
no_body: if False, the Lattice object will end up in an active body, and Part2DObject will be used.
|
||||||
|
no_disable_attacher: if True, attachment properties of Part2DObject won't be hidden'''
|
||||||
|
|
||||||
|
body = activeBody()
|
||||||
|
if body and not no_body:
|
||||||
|
obj = body.newObject("Part::Part2DObjectPython",name)
|
||||||
|
obj.AttacherType = 'Attacher::AttachEngine3D'
|
||||||
|
if not no_disable_attacher:
|
||||||
|
attachprops = [
|
||||||
|
'Support',
|
||||||
|
'MapMode',
|
||||||
|
'MapReversed',
|
||||||
|
'MapPathParameter',
|
||||||
|
'AttachmentOffset',
|
||||||
|
]
|
||||||
|
for prop in attachprops:
|
||||||
|
obj.setEditorMode(prop, 2) #hidden
|
||||||
|
else:
|
||||||
|
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
|
||||||
AppClass(obj)
|
AppClass(obj)
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
if ViewClass:
|
if ViewClass:
|
||||||
vp = ViewClass(obj.ViewObject)
|
vp = ViewClass(obj.ViewObject)
|
||||||
else:
|
else:
|
||||||
vp = ViewProviderLatticeFeature(obj.ViewObject)
|
vp = ViewProviderLatticeFeature(obj.ViewObject)
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,3 +90,6 @@ def screen(feature):
|
||||||
return feature
|
return feature
|
||||||
feature = getattr(feature.Document, feature.Name)
|
feature = getattr(feature.Document, feature.Name)
|
||||||
return feature
|
return feature
|
||||||
|
|
||||||
|
def activeBody():
|
||||||
|
return FreeCADGui.ActiveDocument.ActiveView.getActiveObject("pdbody")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user