how to change SubShapeBinder Support with python (in a Part container)

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

how to change SubShapeBinder Support with python (in a Part container)

Post by easyw-fc »

Hi,
how could I change SubShapeBinder Support with python (in a Part container)?
I have an object contained in a Part which is contained in a second Part container.
I would like to assign to an existing SubShapeBinder to this object selecting the SubShapeBinder and the object itself, and then launching a python command.

What I miss is the way to assign the right 'full parent name' to SubShapeBinder... like in the sample 'Part.Part001.Box.'
Here a code which gives me the wrong Support

Code: Select all

import FreeCAD, FreeCADGui
sel=FreeCADGui.Selection.getSelection()
binder=sel[0]
obj2link = sel[1]
binder.Support = [obj2link]
I would need to get 'Part.Part001.Box.' from the Selection python code...
thanx in advance
SubShapeBinder-test.FCStd
(9.86 KiB) Downloaded 11 times
ssb-Support.png
ssb-Support.png (320.4 KiB) Viewed 380 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: how to change SubShapeBinder Support with python (in a Part container)

Post by Roy_043 »

Code: Select all

sel = FreeCADGui.Selection.getSelectionEx("", 0)
s = sel[0]
Print(s.SubElementNames)
Print(s.Object)
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: how to change SubShapeBinder Support with python (in a Part container)

Post by easyw-fc »

Roy_043 wrote: Sat Jun 25, 2022 4:32 pm ping
many thanks :D
Post Reply