How do I rotate my object?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: How do I rotate my object?

Post by triplus »

freecc wrote: Mon Apr 09, 2018 7:08 pm but now I have to learn quatraneion or whatever, i have to browse Base and Rotations and Placemenets and a zillion classes. Just to rotate?

This is bad. Please fix it. I just want to write some scripts, I don't want to develop your source code. Make it more user friendly. We don't want to look trough all your classes just to rotate something and then send a placement in to another class and change one variable. It is overcomplicated and badly done.
OK therefore you were able to go from total frustration to results:
I did it, with help from God I managed to rotate. I feel good now.
In less then a hour. This leads me to believe FreeCAD after all is doing something right. ;)

P.S. As for "move" maybe you are searching for "translate"? Anyway good to hear you sorted it out.
freecc
Posts: 158
Joined: Wed Feb 21, 2018 4:17 pm

Re: How do I rotate my object?

Post by freecc »

triplus wrote: Tue Apr 10, 2018 12:52 pm
freecc wrote: Mon Apr 09, 2018 7:08 pm but now I have to learn quatraneion or whatever, i have to browse Base and Rotations and Placemenets and a zillion classes. Just to rotate?

This is bad. Please fix it. I just want to write some scripts, I don't want to develop your source code. Make it more user friendly. We don't want to look trough all your classes just to rotate something and then send a placement in to another class and change one variable. It is overcomplicated and badly done.
OK therefore you were able to go from total frustration to results:
I did it, with help from God I managed to rotate. I feel good now.
In less then a hour. This leads me to believe FreeCAD after all is doing something right. ;)

P.S. As for "move" maybe you are searching for "translate"? Anyway good to hear you sorted it out.
I tried for more than an hour my friend :)
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: How do I rotate my object?

Post by mario52 »

hi
the two method

rotation by Euler angle
Rotation(x, y, z)

Code: Select all

object = FreeCADGui.Selection.getSelection()[0]
#object.Placement = App.Placement(App.Vector(X_Base,Y_Base, Z_Base), App.Rotation(App.Rotation(X_Angle, Y_Angle, Z_Angle)), App.Vector(X_Point_Rotation, Y_Point_Rotation, Z_Point_Rotation))) # by  Euler angle
object.Placement  = App.Placement(App.Vector(10.0,  0.0,    0.0),    App.Rotation(App.Rotation(10.0, 10.0, 0.0)), App.Vector(0.0, 0.0, 0.0))
rotation by quaternion
Rotation((x, y, z,) angle)

Code: Select all

object = FreeCADGui.Selection.getSelection()[0]
#object.Placement = (App.Placement(App.Vector(X_Base,Y_Base, Z_Base), App.Rotation(App.Rotation(App.Vector(X_direction, Y_direction, Z_direction),(Angle_rotation))), App.Vector(X_Point_Rotation, Y_Point_Rotation, Z_Point_Rotation))) # quaternion
object.Placement  = (App.Placement(App.Vector(10.0,  0.0,    0.0),    App.Rotation(App.Rotation(App.Vector(10.0,        10.0,         0.0),       (45.0))),        App.Vector(0.0, 0.0, 0.0)))

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply