How to Rotate an Object
-
How can the formula for the coordinate angle want to change the angle?
Thanks very much!edit: This topic has been forked from python-objekte-x-y-z by @ferdinand
-
Hello @WDP,
thank you for reaching out to us. Please follow the rule of separate topics for separate questions for future questions (unless they are direct follow-up questions). I have forked your question from the original topic.
About you question. There is our Python Matrix Manual which goes over the basics of constructing transforms for objects. Furthermore, there are some rotation matrix convenience methods in
c4d.utils
with which an object can be rotated about one of the world frame axes (MatrixRotX
,MatrixRotY
,MatrixRotZ
). The following code from the other thread would for example rotate all objects by 45° on the world Y-axis.for obj in selected: # Get the global matrix of the object, set its offset and write it back. mg = obj.GetMg() mg *= c4d.utils.MatrixRotY(c4d.utils.DegToRad(45.)) obj.SetMg(mg)
Finnaly, you can also access object transforms as parameters, e.g.,
myObject[c4d.ID_BASEOBJECT_REL_ROTATION]
ormyObj[c4d.ID_BASEOBJECT_ABS_ROTATION]
and we have also a quaternion type withc4d.Quaternion
. But these approaches to rotation are only rarely needed, most of the time the global or local matrix of an object retrieved withBaseObject.GetMg()
and.GetMl()
should be the way to go.Cheers,
Ferdinand -
Thank you very much!
-
Hello, I can control the visibility of the objects I know but how can I activate and deactivate the red button?
Thanks very much! -
Hello @WDP,
please follow the rule of opening new topics for new questions.
Thank you for your understanding,
Ferdinand -
Hello that works with the object rotation, thanks, but how can I only rotate the axes without the object rotating?
-
Hello @WDP,
this question would technically also be a new topic, please follow these rules.
There is no formal notion of an object axis in the sense of a moveable entity in the API. Objects have their matrices (the global and the local one), which are effectively their own coordinate system opposed to the world coordinate system (or transform or frame when you prefer these terms over coordinate system).
So, when you want to reproduce what is possible in the app, and move, rotate, or scale the axes of an object, without moving the geomtery of the object itself, then you will have to transform the vertices of that object. So, when the object has the world offset (0, 0, 0) and you want to move the axes to (100, 0, 0), you must first set the global object matrix to an offset of (100, 0, 0) and then apply the inverse of a transform that translates by (100, 0, 0) to all its vertices. I would recommend reading the matrix manual I did post in my first answer here.
This will however only be possible for editable point objects, e.g., a
c4d.PolygonObject
. You are showing a generator object, i.e., ac4d.BaseObject
with some cached geometry in your screenshot. You cannot move the axes for these objects, neither in the SDK nor in the app itself.We had recently this topic which dealt with moving the axes of a polygon object.
Cheers,
Ferdinand