prandall wrote: ↑Sat Nov 30, 2019 5:08 pm
Hello All,
I am trying to add a Placement to a Group object. I would like to be able to use the transform tool like it is used in the Arch work bench.
Something like this:
Code: Select all
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython", "Test")
obj.addProperty("App::PropertyPlacement","Placement","Base","Location of this Member")
...
I'm not sure how to achieve what you want, but maybe you can investigate the code of
Arch Building for clues.
The old Arch Building is a class of type
ArchBuilding._Building. It creates an object derived from a
Std_Group, that is,
App::DocumentObjectGroupPython.
Code: Select all
def makeBuilding(objectslist=None,baseobj=None,name="Building"):
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython","Building")
_Building(obj)
However, the newer
Arch Building is derived from
Arch BuildingPart.
https://github.com/FreeCAD/FreeCAD/blob ... #L232-L238
Code: Select all
def makeBuilding(objectslist=None,baseobj=None,name="Building"):
"""overwrites ArchBuilding.makeBuilding"""
obj = makeBuildingPart(objectslist)
obj.Label = name
obj.IfcType = "Building"
The BuildingPart is a class of type
ArchBuildingPart.BuildingPart. It creates an object derived from
App::GeometryPython
https://github.com/FreeCAD/FreeCAD/blob ... #L202-L210
Code: Select all
def makeBuildingPart(objectslist=None,baseobj=None,name="BuildingPart"):
obj = FreeCAD.ActiveDocument.addObject("App::GeometryPython","BuildingPart")
#obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","BuildingPart")
obj.Label = translate("Arch","BuildingPart")
BuildingPart(obj)
Then this object is extended by an
App::GroupExtensionPython.
https://github.com/FreeCAD/FreeCAD/blob ... #L319-L329
Code: Select all
class BuildingPart(ArchIFC.IfcProduct):
def __init__(self,obj):
obj.Proxy = self
obj.addExtension('App::GroupExtensionPython', self)
#obj.addExtension('App::OriginGroupExtensionPython', self)
self.setProperties(obj)
This sounds to me that you can do the same: create a basic App::GeometryPython object, and then extend it to behave as a group.
The other alternative is the opposite way, which is what you proposed initially: create a basic group, and then extend it with the correct class (GeometryExtension or something like that?).