CINEMA 4D – Get Python Object/Tag ID

Last updated on October 22nd, 2018,

One thing you will do over and over when scripting for Cinema 4D is look for Object and Tag Types.

These are accessed by a unique ID. This little script will help you find the correct Type ID, Name and Tag parent Object of selected Objects and Tags:

import c4d
from c4d import gui

def main():
#CallCommand(12305)
#CallCommand(13957)
#doc=GetActiveDocument()
obj=doc.GetActiveObject();

print "#############################"

if obj:
    print "Object:", obj#, obj.GetType(), obj.GetName()
else:
    print "no Object selected"

tag=doc.GetActiveTag();
if tag:
    print "Tag:", tag, " on Object: ", tag.GetObject()
else:
    print "no Tag selected"

print "#############################"

if __name__=='__main__':
main()

 

Share

Alex from CGDirector - post author

Hi, I am Alex, a Freelance 3D Generalist, Motion Designer and Compositor.

I have built a multitude of Computers, Workstations and Renderfarms and love to optimize them as much as possible.

Feel free to comment and ask for suggestions on your PC-Build or 3D-related Problem, I'll do my best to help out!

2
Comments

Aivaras

Hi Alex,
Thanks for this useful snippet, however, It’s broken due to missing indentation in your code.