CINEMA 4D – Get Python Object/Tag ID

17 November 2015

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()

 

Alex - post author

Hi, I am Alex, a Freelance 3D Generalist / Motion Designer and Compositor currently living in Frankfurt, Germany.

I have built a multitude of Workstations and Renderfarms for all kinds of 3D related use cases and love to optimize them as much as possible.

After working in the 3D/VFX Industry on-staff for several years, I have recently gone freelance and am having a blast!

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

2
Leave a Reply

avatar
  Subscribe  
newest oldest most voted
Notify of
Aivaras
Guest

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