The file posted has two coincident cubes at the origin and a Coordinate system for reference.
Let us first consider the effect of two pure rotations. Pure means rotations about the origin with no accompanying translations.
We want rotate first by angle1 about (global) axis1, followed by a rotation of angle2 about axis2.
Code: Select all
import Draft
ZEROVEC = App.Vector(0, 0, 0)
axis1 = App.Vector(0, 0, 1)
angle1 = 45
axis2 = App.Vector(0, 1, 0)
angle2 = 30
Code: Select all
doc = App.ActiveDocument
obj = doc.getObject('Box')
Draft.rotate([obj], angle1, ZEROVEC, axis1)
Draft.rotate([obj], angle2, ZEROVEC, axis2)
doc.recompute()
Code: Select all
obj1 = doc.getObject('Link')
rot1 = App.Rotation(axis1, angle1)
rot2 = App.Rotation(axis2, angle2)
obj1.Placement.Rotation = rot2 * rot1 * obj1.Placement.Rotation
doc.recompute()
The results are the same - both manipulate the Placement - the latter directly.
If we consider a more general rigid motion, described by a Placement:
Code: Select all
App.Placement(translation, rotation, center)
Reset the placements:
Code: Select all
obj.Placement = App.Placement()
obj1.Placement = App.Placement()
doc.recompute()
Code: Select all
import Draft
ZEROVEC = App.Vector(0, 0, 0)
translation1 = App.Vector(0, 0, 0)
translation2 = App.Vector(0, 0, 0)
center1 = App.Vector(0, 0, 0)
center2 = App.Vector(0, 0, 0)
axis1 = App.Vector(0, 0, 1)
angle1 = 45
axis2 = App.Vector(0, 1, 0)
angle2 = 30
doc = App.ActiveDocument
obj = doc.getObject('Box')
Draft.rotate([obj], angle1, center1, axis1)
Draft.move([obj], translation1)
Draft.rotate([obj], angle2, center2, axis2)
Draft.move([obj], translation2)
doc.recompute()
Code: Select all
obj1 = doc.getObject('Link')
obj1.Placement = App.Placement(translation2, App.Rotation(axis2, angle2), center2) * \
App.Placement(translation1, App.Rotation(axis1, angle1), center1) * obj1.Placement
doc.recompute()