Macro StraightenObject

This page is under construction/update

Context
This macro has been written mainly re-align imported objects (eg. STEP) with main FreeCAD planes/axis.

Usage
Functionally, the macro will use one or both of following reference items to straighten (rotate & move) the object(s) :
 * Face : the selected face will be set coplanar with XY plane, its center mass being set at the origin
 * Edge (or 2 vertexes) : the selected edge will be aligned with the Y axis

To use the macro, select the reference item(s), eventually other objects, then run the macro. If you want to align your object with other plane/axis, use the macro then the Transform function of FreeCAD.

Installation
At the moment, the macro isn't available from the addon manager => PR submitted : https://github.com/FreeCAD/FreeCAD-macros/pull/55 So you have to copy the below code and paste it in FreeCAD macro editor.

For more detailed explanations, see the How to install macros page.

Details
Below a table presenting the different cases that are handled by the macro :

To Be Completed with picture example

Limitations

 * Reference items shall all belong to the first selected object. Reference items among several objects is not supported at this time
 * Straightened object(s) shall be in a coordinate system corresponding to the global one. If you used Part container(s) to locate your objects, you should first use Macro PlacementAbsolufy on your model. If this condition isn't fulfilled, weird things can happen.

Forum discussion
For any feedback (bug, feature request, comments, ...), please use this forum thread : https://forum.freecadweb.org/viewtopic.php?f=22&t=35191