I'm working on a macro where objects are always put in a Part(A), and in (A) there can be multiple Parts B,C,D.
My goal; The sub Part placements (relative to each other) need to stay where they are but I want to set the Parent position to 0,0,0. To do this I plan to add all the Parent position offsets to the sub obects and then 0,0,0 the Parent.
I have the current selected Part by selection and then using "getParentGeoFeatureGroup()" I work up the ladder. I then use getParentGeoFeatureGroup() again to find the Parent Part (A). Now I want a list of all sub Part objects in the Parent. Is there a call or do I need to iterate something, that's my question, I haven't done this prior. I know I need to create a list and then find the Part objects and put them in the list, then crunch the numbers on each of the Part placements.
Thank you
Setting Parent Part to zero by offsetting SubParts
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Setting Parent Part to zero by offsetting SubParts
I case anyone else is looking I found a snip of code:
Code: Select all
for obj in App.ActiveDocument.RootObjects:
if str(obj) == "<Part object>":
App.Console.PrintWarning("Part object " + str(obj.Name)+"\n")
if FreeCADGui.Selection.getSelection()[0] == obj:
for subobj in obj.OutList:
App.Console.PrintWarning("found sub Part object " + str(subobj.Name)+"\n")
# if FreeCADGui.Selection.getSelection()[0] == subobj:
# if str(subobj.Name) == "Part003":
if subobj.TypeId != "App::Origin":
print("found the Parts ...............", subobj.Name)
doc.getObject(self.my_obj.Name).Placement = App.Placement(App.Vector(0.0,0.0,0.0),App.Rotation(App.Vector(0,0,0), 0.0))
FreeCADGui.updateGui()