Need some coding help, macro included

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Need some coding help, macro included

Post by freedman »

The goal is to select an edge and the macro will highlight the associated face. I made a simple macro so if a Body object is selected in the tree it will exit, simple enough. Start the macro and select an edge.

I am attaching a file but it is just a cylinder.

I'm having a problem here:

Code: Select all

for fac in faces:
	if fac.Surface.isPlanar():
        	print("Found planar face",fac)
                Gui.Selection.addSelection(self.doc.Name,'Body',fac) 


I can't figure out what AddSelection needs to work correctly.
Thank you
Attachments
disk1.FCStd
(11.33 KiB) Downloaded 10 times
Additive1.FCMacro
(2.23 KiB) Downloaded 10 times
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Need some coding help, macro included

Post by freedman »

Got it. I'm close, now I need to use edwilliams code to select which face to use.
Attachments
Additive2.FCMacro
(2.36 KiB) Downloaded 10 times
Post Reply