Dialog creator for 2D sections of beams

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
oddtopus
Posts: 142
Joined: Tue Sep 20, 2016 6:17 pm

Dialog creator for 2D sections of beams

Post by oddtopus »

Hi, I started to work on the subject here, to include that in dodo wb later.
At this time the dialog is already working: if you wish to try it, just copy the files of the folder in your macros path and then type

Code: Select all

import dialog4
in the python console.
Image

Now, I'd like to move the section so that its CenterOfMass lies in the origin but somehow this code doesn't work in the execute() method:

Code: Select all

        p = Part.makePolygon([p1,p2,p3,p4,p5,p6,p1])
        s = Part.Face(p)
        v=s.CenterOfMass.negative() 
        s.translate(v) # to move the c.o.m. in (0,0,0). Why does it not work?
        obj.Shape = s
What happens is that the polygon and the face are created correctly and also assigned to the .Shape of obj. But the face is not translated as requested after the .recompute() of the ActiveDocument.

The strange thing is that if I type each line in python console to a) create the polygon and b) create the face and c) translate the face and finally d) Part.show(s), it DOES work!

Is there a difference in the .execute() method from the Part.show() command that makes the .translate() operation uneffective?

Suggestions are welcome. Thanks in advance.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Dialog creator for 2D sections of beams

Post by Kunda1 »

oddtopus wrote: Sun Jun 23, 2019 9:20 am Image
Path to image was broken. Here is the correct URL:
Image
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply