SOLVED Mograph Objects Python

Hi,

I searched in this forum about the creation of Mograph Objects in Python and the posts I found are +5 years old.

I would like to know if as of 2022 there is a way to get c4d.BaseObject(c4d.Omgcloner) and c4d.BaseObject(c4d.Omginheritance) working.

Thank you for your time.

Joel.

@joel
What you mentioned now is available in c4d 2023 version.
Snipaste_2022-11-10_12-04-07.png
Here is the link: Cinema 4D SDK 2023.1.0 documentation

Thank you so much. As it turns out I was in version 26.013 and I had to uninstall it as I was not able to update it and then reinstall the newer version.

Hello @joel,

Thank you for reaching out to us and thank you @iplai for providing the answer.

There is not much to add for us here. Prior to 2023.0.0 there were some larger gaps in the type symbol definitions of classic API nodes, e.g., objects, tags, materials, shaders, Xpresso nodes, scene hooks, etc, because they were never defined in the frameworks (so this was not just a Python thing, even in our internal C++ API they were more or less hardcoded). One major offender was your use case, MoGraph. With 2023.0.0 I have added the cases which I considered most important for public users, objects, materials, shaders, tags and Xpresso nodes. But there are still some gaps in more fringe node types as for example scene hooks, because it is quite a bit of work to pull them out of our code base.

With that being said, a type symbol is just that: a symbol. They stand for the integer ID with which the type is being registered. You can always use the raw integer value or just define a symbol for the integer value yourself.

import c4d

# Define the two symbols yourself and attach them to the c4d module.
c4d.Omgcloner: int = 1018544
c4d.Omginheritance: int = 1018775

def main():
    """
    """
    a: c4d.BaseObject = c4d.BaseObject(c4d.Omgcloner)
    b: c4d.BaseObject = c4d.BaseObject(c4d.Omginheritance)
    if None in (a, b):
        raise MemoryError("Object allocation failed.")
    
    doc.InsertObject(a)
    doc.InsertObject(b)
    
    c4d.EventAdd()

if __name__ == "__main__":
    main()

An uncomplicated way to find out these type symbols is the console and the method C4DAtom.GetType (all classic API nodes are of type C4DAtom). Drag the thing you are interested in into the console (e.g., the Inheritance object) and type after it .GetType() and press Enter:

gettype.gif

Cheers,
Ferdinand