[solved] Rotation - how to rotate twice?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: Rotation - how to rotate twice?

Post by dprojects »

edwilliams16 wrote: Mon Jun 20, 2022 9:24 pm In my opinion using yaw/pitch/roll is not at all suitable for your application.
The Draft_Rotate function does all the dirty job for me very well. I don't know who coded the function but he did good job and the function it is very cool, this is how API should looks like.

What is very surprising to me, it not work with Pads, but it works also with Constriction Profiles made from PartDesign::Thickness, so I got exactly what I wanted. I can rotate Cube panels and also other more complicated objects.

Image

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: Rotation - how to rotate twice?

Post by dprojects »

mario52 wrote: Tue Jun 21, 2022 9:44 am example of macro Macro_Rotate_To_Point Image
mario
Thanks, Mario, I see you wrote a lot of code for FreeCAD. I have linked your site, this is good tutorial how to deal with things at FreeCAD.

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: [solved] Rotation - how to rotate twice?

Post by keithsloan52 »

I think Munther Hindi has a better solution

If you want to rotate objects programmatically (say in a Macro) using two successive rotations about two different axes then you could use something like:

rot1 = FreeCAD.Rotation(FreeCAD.Vector(x1, y1, z1), angle1) # rotation about axis with components x1, y1,z1 with angle1 in degrees

rot2 = FreeCAD.Rotation(FreeCAD.Vector(x2, y2, z2), angle2) # rotation about axis with components x2, y2, z2 with angle2 in degrees

Then to rotate object about the two axes, some thing like,

obj.Placement.Rotation = rot2*rot1 # this rotates about axis 1, then axis2, but double check visually.
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: [solved] Rotation - how to rotate twice?

Post by edwilliams16 »

freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: [solved] Rotation - how to rotate twice?

Post by freedman »

I finished my part design assembly last night, I will post the code in the next few days. Maybe that will help.
Been building models to test.
Attachments
GIF dialog UI.gif
GIF dialog UI.gif (207.61 KiB) Viewed 842 times
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: [solved] Rotation - how to rotate twice?

Post by dprojects »

freedman wrote: Wed Dec 14, 2022 12:17 am I finished my part design assembly last night, I will post the code in the next few days. Maybe that will help.
Been building models to test.
Very nice. This support containers like LinkGroup? Currently I want to improve this part at Woodworking workbench. The containers are little "not supported" well as they should. What I saw that getGlobalPlacement is not correct in case of LinkGroup. It works only with containers like Part, Body.

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
freedman
Veteran
Posts: 3436
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: [solved] Rotation - how to rotate twice?

Post by freedman »

dprojects wrote
It works only with containers like Part, Body.
That's where I am also, I was hoping to look at Links but what was more important to me is fast simulations. I think I got Links to work in another macro but maybe LinkGroups were a problem.
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: [solved] Rotation - how to rotate twice?

Post by dprojects »

freedman wrote: Wed Dec 14, 2022 7:13 pm That's where I am also, I was hoping to look at Links but what was more important to me is fast simulations. I think I got Links to work in another macro but maybe LinkGroups were a problem.
This is not only problem with LinkGroup but the vertices for faces and edges are not updated even for Body and Part containers: https://forum.freecadweb.org/viewtopic.php?f=22&t=74447

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
HardCAD
Posts: 1
Joined: Tue Jul 14, 2020 4:48 pm

Re: [solved] Rotation - how to rotate twice?

Post by HardCAD »

For rotating pads more than once, a trick I found useful is to make a fusion of the pad with something (part > fusion of the two parts).

This resets the rotation to zero so you can add another rotation without having to go through the math/scripts.
User avatar
dprojects
Posts: 721
Joined: Mon Mar 06, 2017 6:02 pm
Location: Poland
Contact:

Re: [solved] Rotation - how to rotate twice?

Post by dprojects »

HardCAD wrote: Fri Feb 03, 2023 5:50 pm resets the rotation to zero
You read my mind, bad boy ;-) Reset rotation to zero can be used to determine the plane correctly for rotated objects but I didn't released it yet with this way ;-) Are you time traveler? ;-) LOL

Thanks
Darek
github.com/dprojects

workbench for woodworking is available at: github.com/dprojects/Woodworking
Post Reply