MoData Question - only in effectors?


Dear coders,

As you may have seen from some other threads, in my coding hobby project I hit a snag that prompted me to dive into Python. Something I thought wasn’t possible in COFFEE, and was in Python - the GeGetModata command. But after a chat with Douwe I realize I better ask before I go on another wild goose chase. It seems this is not related to the script language. So I’ll explain what I am trying to do.

I need to read data from MoGraph objects, such as the object type, linked object references and several other #MG_ ID’s. Also I need the matrices of indexed nodes. I want to use this info to do things to other[B] objects in the scene, not to the cloners/matrix objects that I am reading from. Things like create or remove objects, move them around, etc. The Xpresso MoGraph data node is not an option for getting the data I need, because the script relies on recursion.

So far, I can do this in an Xpresso node script - up to the point where I need the matrix data, this is where I hit the roadblock - I cannot execute the GeGetModata command (at least in COFFEE). According to Douwe, this is because it only works in effector.

So how do I fix this?
[li]Does moving to Python help at all, can I use the GeGetModata command in an Xpresso node script there? Or does it also need an effector?
[/li][li]Can I port my script to an effector and still do the things I want to do to the rest of the scene? In what script language?

Thanks a lot if you can help me, I am putting a lot of time and effort in this project and it’s going to be lovely - if it works. Very vexed…

Dr. Scarlett


If you only want to read them:

# r13 only
  # for scriptmanager
   import c4d
   import c4d.modules.mograph as mograph
   data = mograph.GeGetMoData(op)
   mats = data.GetArray(c4d.MODATA_MATRIX)
   for mat in mats:

But I don’t belive that you can set the data from the script-manager. Of course you can use this in a Node or a Tag, too. Haven’t done anything with Mograph and Python yet, sorry.



Thanks a lot Niklas,

I am using r12 and I have been experimenting all day - I can run the commands in an effector, but those only read data from Mograph objects affected by the effector (you have to actually run the GeGetMoData command on the effector object). I cannot find out how to single out an individual object from this affected group (was thinking about trying to trick things by adding and removing the effector to the in/exclude lists of the objects to access their data individually). Also the effector script execution timing seems strange to me…
[EDIT: I found out that the effector script, in full control, triggers once for each affected MoGraph generator object. You can see during each trigger which object is receiving an effector script cycle at that time, and work with it. But you can’t see how many there are in total or how many their will follow. I need my script to run once every frame with all the Mograph object information available. Maybe if I combine this with some Xpresso/COFFEE/user variables, I can make it so, but I’m not confident… By the way, it looks like the MoGraph generators generate new clone objects each cycle - whoah…]

I might need to upgrade then before I continue, so please don’t mind if I ask for confirmation: are you sure I can get those MoData arrays - especially the matrix data of the cloned (generated) objects - by accessing the individual Mograph objects directly from inside ‘normal’ scripts in r13 Python? What about COFFEE in r13?

Anyway I’ve already started to port my script to Python, so that last question is less important.

Thanks again to you, or to anyone who might add anything for my information.

Dr. Scarlett


I can’t help thinking going to R13 will help you a lot.
While you might do round trips via all sorts of nodes
(iterators, hierarchy, data etc)in xpresso to get what
you’re looking for, having it “all” in Py will make
you’re life so much easier and more portable.

Py will additionally add so much more possibilities
like ready to run libraries of all kind.
(Done some EXIF and Geodata setups for camera and archviz work
fairly easy from libs on the net).

A generic MoChecker might look like this, returning
BaseCount, effective count and Matrices for each Clone.

import c4d
from c4d import gui
from c4d.modules import mograph as mo
#Welcome to the world of Python

def MoCheck(obj):
    md = mo.GeGetMoData(obj)
    if md == None: return None,None,None
    clist  = []

    marr   = md.GetArray(c4d.MODATA_MATRIX)
    farr   = md.GetArray(c4d.MODATA_FLAGS)
    ccount = len(marr) # Initial Clone count
    for i in xrange(ccount):
        if ((farr[i]&(c4d.MOGENFLAG_CLONE_ON)) and (not (farr[i]&(c4d.MOGENFLAG_DISABLE)))): #Only if the clone is visible
            clist.append(marr[i]) # Add Clone Matrix to the list
        else: ccount -= 1 # Adjust Clone count

    return len(marr),ccount,clist

def main():
    if op is None: return True
    print MoCheck(op)
if __name__=='__main__':



OMG Lennart,

again, you are a life-saver. :bowdown:
Now I can take a break from this crusade while I upgrade :slight_smile: Pffffffff

Thanks a lot man, I could not have hoped for more positive confirmation!

Dr. Scarlett :beer:


Hi Lennart, (and others of course)

just to clarify, how can a clone be disabled or invisible in the MoData, i.e, show up with MOGENFLAG_CLONE_ON on false or MOGENFLAG_DISABLE on true?

Does it have to do with disabling the generator flag of the parent cloner object or the visibility flag of the cloned object, and if so, could it be possible for individual clones to have differing flags in the MoData?

Thanks in advance,

Dr. Scarlett


The bits are set by i.e Effectors (Visibilty) and the “Fill” parameter
of a cloner.



click another puzzle piece falling into place.

By Jove, did I struggle with the fill parameter when I was trying this in COFFEE. A week ago, I almost asked around for the calculation method that uses the fill parameter to determine the clone count.

Interesting… the clones are there, only… not.

ThanQ Lennart!
Dr. Scarlett


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.