Macro Rotate To Point/en

Description
Macro to rotate an object on itself with the axis of rotation being either the:
 * boundbox center
 * center of mass
 * direction of wire
 * last point clicked

Usage

 * 1) Download the macro from the Addon Manager
 * 2) Execute the macro
 * 3) Select one object
 * 4) Choose one of the following orientations:



Point Rotation

 * Boundbox Center: Select the BoundBox center to axis rotation
 * Center of Mass: Select the Center of Mass to axis rotation
 * Point Clicked: Select the last mouse click as the point for axis rotation
 * 1: select the object
 * 2: use the key to choose an extra object

Axis Rotation

 * Rotation(Z) Yaw: Yaw axis
 * Rotation(Y) Pitch: Pitch axis
 * Rotation(X) Roll: Roll axis
 * Rotation(D) Direction: Rotate around line, wire selected

Coordinates Point clicked

 * DoubleSpinBox: Coordinate X on mouse click (modifiable only with the mode "Point Clicked")
 * DoubleSpinBox: Coordinate Y on mouse click (modifiable only with the mode "Point Clicked")
 * DoubleSpinBox: Coordinate Z on mouse click (modifiable only with the mode "Point Clicked")

Work

 * If this checkBox is the rotation is disabled, the object placement is done on the axis selected.
 * One point is created for visualise the point rotation axis: red X, green Y, blue Z
 * Line Edit: The line edit displays the original coordinate to axis selected + the input data given in the spinBox
 * Enter the modification
 * Apply the modification to the object
 * The coordinate is displayed

Data

 * Window for display the coordinates memorized
 * Save the data in file
 * Delete and clean the text editor
 * Delete the selected line
 * Memorize and display the coordinate
 * Mode normal the coordinate is saved in this mode : [(0.06,1.30,0.0),(85.0,0.0,0.0)],
 * Mode macro  the coordinate is saved in a complete macro directly in your macros directory with the same name of the document extention .FCMacro
 * Options of the macro
 * __pompe____engrenage__ : Name of document
 * __22 Coordinates__ : number of coordinates
 * Type Key Q to Quit : Quit the macro
 * Type Key D to Decrease speed : Decrease the speed of the animation
 * Type Key I to Increase speed : Increase the speed of the animation
 * Type Key P to Pause/Continue or key RETURN or ESCAPE : Pause / Anime
 * Type Key S to Step by Step (key RETURN or ESCAPE to continue) : Step by Step
 * Type Key M for this message : Display this memo
 * ____________________________
 * Mode normal : The data is not saved on window, you must push the  button for save the coordinate
 * Mode Memo on Click  : The data is automaticly saved with all click op the  button
 * Mode normal : The data is not saved on window, you must push the  button for save the coordinate
 * Mode Memo on Click  : The data is automaticly saved with all click op the  button

Command

 * Quit the macro
 * After modifying the data of the object you can return to the original placement, If you have not deselected the current object.
 * This option places the object in base coordinate
 * Reset the data in the macro and deselect the current object (same mouse click in the 3D view)

Script
ToolBar Icon PNG  SVG

Macro_Rotate_To_Point.FCMacro

Links
The forum feature req: placement - rotate part around its midpoint My macro to Gist mario52a

Version
2021/01/12 ver 00.06 : adding the Data section and more options

2020/03/07 ver 00.05.2 : correct the bug translation delete "direction = myObject.Placement.Rotation.multVec(direction)"

2020/03/01 ver 00.05.1 : correct the position of the test "FreeCAD version"

2020/02/29 ver 00.05 : convert to Hdpi (Layout) and add Direction

06/04/2019 ver 00.04 : Python 3

29/03/2018 ver 00.03 : comment the "FreeCAD.ActiveDocument.recompute" the change value are too slow with complex element in FreeCAD 0.17.... see FC0.17 recompute strange behaviour (regression)

27/03/2017 ver 00.02 : modify the spinbox "Pos" now accept the negative values

05/03/2017 ver 00.01 : add 3 spinbox for displayed the coordinates X Y Z on click mouse

04/03/2017 ver 00.00