On 19/12/2014 at 16:41, xxxxxxxx wrote:
#R14
#While generating objects using Python Generator
Hi all! The past week or so I have been getting familiarized with Python in C4D (longtime programmer in several other languages before this). I've been hitting roadblock after roadblock, but probably nothing out of the ordinary.. and I haven't found anything that has totally stumped me.. until now!
I am trying to access (read) the MoData from a Matrix object I have created within Py code. If I try to access a Matrix object linked through userdata/OM, I do not encounter this problem.
I suspect that it has something to do with the hidden "MoData Tag" I have seen referenced a few times. I found that my OM linked Matrix had the hidden tag, and my procedural one did not come with it. I was able to "MakeTag()" on my procedural Matrix object and successfully read MoData using "GeGetMoData", but the arrays were empty upon trying to read them (see bottom code example) :P
Here is the test code showing my issue
import c4d
from c4d.modules import mograph as mograph
#Welcome to the world of Python
def main() :
matrixObject = c4d.BaseObject(1018545) #new Matrix Object
modata = mograph.GeGetMoData(matrixObject)
print modata #prints "None"
matrixObject2 = op[c4d.ID_USERDATA,1] #Matrix Object linked from OM
modata2 = mograph.GeGetMoData(matrixObject2)
print modata2 #prints appropriate MoData object definition
And here is an example trying with the MoData Tag
import c4d
from c4d.modules import mograph as mograph
#Welcome to the world of Python
def main() :
matrixObject = c4d.BaseObject(1018545) #new Matrix Object
matrixObject.MakeTag(1018625) #add MoData Tag
modata = mograph.GeGetMoData(matrixObject)
print modata #prints appropriate MoData definition (unlike before)
matrixObject2 = op[c4d.ID_USERDATA,1]
modata2 = mograph.GeGetMoData(matrixObject2)
print modata2 #prints appropriate MoData definition
modata_positions = modata.GetArray(c4d.MODATA_MATRIX)
print modata_positions #empty
modata_positions2 = modata2.GetArray(c4d.MODATA_MATRIX)
print modata_positions2 #filled with Data
Is there a way I can force the procedural Matrix object to update its MoData Tag before using GetArray() to read said data?
Hopefully I am just missing something here. Thank you for any and all help!