Automatically detect rotational symetry

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
cw_fa_cad
Posts: 3
Joined: Fri Oct 19, 2018 11:34 am

Automatically detect rotational symetry

Post by cw_fa_cad »

Hi Everyone,

i am relatively new to FreeCAD and want to use for automatic feature detection of parts, so I process them programmatically.
My question is, is there any easy way to detect wether a part is rotational symetric via a python script.

Thanks a lot, any help is greatly appreciated.
wmayer
Founder
Posts: 20300
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Automatically detect rotational symetry

Post by wmayer »

If you have a rotational body then an axis must exist where all sections of this body with planes that are perpendicular to the axis are circles.
And out of symmetry reasons the axis must go trough the center of gravity of the body.

The Python API of a shape offers the attribute "PrincipalProperties" which is a dict that contains three axes of inertia. One of these axes is the direction vector of the needed axis.

So, if you have determined the the axis you build some planes with the normal equal to the axis direction. If the section of all planes with the body returns a circle you can be pretty sure that it has a rotational symmetry.
Post Reply