I could've sworn I have seen some kind of comment on this some time ago, but I can't find it any more, so maybe it was just in my perverted fantasy...
Access to the elements of a vector in a matrix doesn't seem to work as expected. Compare the following two attempts:
import c4d
from c4d import gui
class abc:
def __init__(self):
self.v = c4d.Vector(1.0)
def main():
# works fine:
abc1 = abc()
print (abc1.v, abc1.v.x)
abc1.v.x = 9.9
print (abc1.v, abc1.v.x)
# does not work fine:
mat = c4d.Matrix()
print (mat.off, mat.off.x)
mat.off.x = 9.9
print (mat.off, mat.off.x)
if __name__=='__main__':
main()
The test class abc
contains a c4d.Vector()
. Changing the vector's attributes (here x
) works fine.
Then I try the same with a c4d.Matrix()
. Here, it doesn't work. The line mat.off.x = 9.9
does not change the vector's x
attribute. It doesn't raise an error either - it just ignores the value completely. To make changes to off
, I have to swap the complete vector against another one: mat.off = c4d.Vector(9.9, mat.off.y, mat.off.z)
or something like it.
I assume that this behavior results from Matrix
not being a true Python class, but a wrapper object for a C++ object. But I can't find any comment on that. I believe I even saw that kind of deep reference being used in one sample in the documentation, although I may have hallucinated that (chanterelles, I swear it was chanterelles).
(While I'm at it: could someone amend the documentation on the Vector operators *
and ^
when the other operand is a matrix? The text does not mention that one is the equivalent to Matrix's Mul
, while the other is MulV
. Even the code samples are the same! Which is technically correct as the matrix used in that sample is a scale matrix with no translational component, but it's quite misleading.)