Let me reply on the company account as I'm not at home, thank you very much for this information.
This is a much more simplified and clean way to go about it indeed, I did spend some time on Google before composing my code and even asking here.
Thank you for answering even though it is out of the scope of this forum technically, much appreciated.
I have tons of C4D python code that works, so no questions about that so far
I imagine this will work just fine, going to adapt it into my script.
@ferdinand : Thank you for the pointers to the articles, and I fully understand that you do not have the time to explain the more complex parts of the Matrix concepts.
I will read the material you have provided and otherwise search for info on Linear Algebra to get a better undertstanding.
I think I understand it a bit better now, basically those 3 numbers per axis (X,Y,Z) basically tell you along which world axis they lie.
So the main columns are X,Y,Z and then each row is technically X,Y,Z as well.
X Y Z
X X X
Y Y Y
Z Z Z
With the help of Cairyn I've figured out that the issue is with the transforms of parents and grandparents, so I will rewrite my code to remove all of those as well and this should hopefully fix the issue.
Thank you very much for your help and should I run into further issues on this, I will post again in this thread!
@ferdinand Thanks again for this extensive explanation, I will be sure to keep this at hand for reference.
I do indeed grasp the concepts of multiple layers of coordinate systems but my issue specifically with the Matrix manual is that when I look at for instance the second image, with the nice colored columns for each component (Or so it would seem to me).
Then when I see the 3rd image I see the number "1" jump colums which is the part that makes it confusing to me. I believe in the dabble I had with matrices that default "1" is the scale but I don't grasp why it doesn't just stay in one of the colored columns.
Another time when I read out the matrix of an object that had rotations on it, the matrix showed everything 0 apart from those 3x default 1 jumping columns.
So it appeared the matrix did not have any rotational values stored.
Again, this confused me.
To be open and honest here, I'm a visual artist that has started to do coding to make internal company tools and while I have an ok understanding of math some things like this I can't yet visualise for myself so I don't fully understand it yet.
The parent doesn't have the transforms but the grandparent indeed does, which seems to be the issue indeed.
I've already got my code to move the points around to the old relative transformations so I'll re-use that one for these purposes.
The Subdivision Surface object two up has rotation on it, below that is a null with only a scale of 1.3 and inside that null is my object.
So if I store the points in my object and then reset the rotation of the SubS and scale of the null, and then put them back, all should be good.
I'm making an in-house turntable tool to isolate out objects in complex scenes and I get to see all kinds of weird modelling actions from team members and externals that I need to catch and correct This is one of them.
But say I wanted to rotate the pivot point to offset parent(s) transformations, how would I go about doing that in code?
@ferdinand : Thanks a lot for replying in such an extensive manner, that code was really helpful in it's own way but for other purposes.
Your code actually rotates and moves my object, which I do not want. I want it to remain in exactly the same location and orientation but I want it's axis system to match up to that of the world.
It seems I wasn't detailed enough in my initial question:
The object has no rotational transforms (all are 0) but the Pivot ("Enable Axis" button) is incorrectly oriented. The objects' local coordinate system does not match up with the worlds' coordinate system in terms of orientation (X-axis, Y-axis, Z-axis).
Normally, as a human, one would press the "Enable Axis" button and manually rotate the objects'' Pivot point to match the orientation of the world axis. So that Y is up, etc.
How would one do this in Python code?
Currently the Y axis of the object is on the worlds' X axis, so if I call the GetRad() function, the width of the object is actually put in the Y component of the c4d.Vector, not in the X where it should belong.
Edit: I have read up on the matrix manual but it's confusing to me, but that is a different subject.
I've got a question that I can't seem to solve myself and neither is Google being of much help.
I've got an object of which it's local axis are not aligned with the world axis.
In this case:
The y of the object is on the x of the scene
The x of the object is on the -z of the scene
The z of the object is on the -y of the scene
I'm trying to build a custom bounding box for an internal tool and as you can imagine, reading of GetRad along completely wrong axis will give me an incorrect bounding box.
So I will need to align the axis of the object to the world axis first and then do my GetRad.
Normally as human, one would rotate the pivot point of the object to align with the world, however I would like to do this in code, as this will be part of a recursive loop going through a list of objects.
I've tried fiddling around with the matrices but this did not result in anything.
Well, that indeed fixed the issue, now the size gets properly updated!
Thank you very much for the help
I have a technical Python question which I can't seem to solve.
The following script is used to store the points in an object, then reset the rotation of the object and then put the points back into their old position:
if (Object.GetType() == c4d.Opolygon) or (Object.GetType() == c4d.Opoint):
oldm = Object.GetMg()
points = Object.GetAllPoints()
pcount = Object.GetPointCount()
newm = Object.GetMg()
for p in range(pcount):
This works very well, however I'm running into a problem if I look under the Coordinate Manager of the object and then it's size. Under size the object still appears to be in it's old orientation at first glance.
However, if I click on any of the size values and then simply hit enter, all the values jump around to the give the object it's correct orientation again.
For instance, the longest axis is initially the "Z" axis (old orientation) but when I click the value and hit enter, the contents of the "Z" axis jump to the "Y" axis where they should be.
My question is two fold:
Currently I read the bounding box of the/multiple objects and compile a custom bounding box afterwards, but this currently has the wrong orientation because the size parameters are not in the correct axis.