This great Cinema 4D Python Script automatically adds object buffers with names…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
import c4d from c4d.documents import GetActiveDocument def GetNextObject (on): if op==None: return None if op.GetDown (): return op.GetDown () while not op.GetNext() and op.GetUp(): on op.GetUp = () Return op.GetNext () def add_channel(tagname, tagchannel): buffer = c4d.BaseList2D(c4d.Zmultipass) buffer.GetDataInstance()[c4d.MULTIPASSOBJECT_TYPE] = c4d.VPBUFFER_OBJECTBUFFER # Check for existing MPs rd = doc.GetActiveRenderData() vp = rd.GetFirstMultipass() exist_buffer = 0 while vp: if vp.GetTypeName() == "Object Buffer": if vp[c4d.MULTIPASSOBJECT_OBJECTBUFFER] == tagchannel: print "channel "+ str(tagchannel) + "Present" exist_buffer = 1 vp = vp.GetNext() if exist_buffer == 0: buffer.SetName ( tagname ) buffer[c4d.MULTIPASSOBJECT_OBJECTBUFFER] = int(tagchannel) rd.InsertMultipass (buffer) def main(): doc = GetActiveDocument() all_op = doc.GetFirstObject() while all_op: tags = all_op.GetTags() for tag in tags: if tag.CheckType(c4d.Tcompositing): if tag[c4d.COMPOSITINGTAG_ENABLECHN0] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN0] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn1] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN1] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn2] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN2] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn3] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN3] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn4] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN4] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn5] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN5] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn6] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN6] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn7] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN7] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn8] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN8] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn9] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN9] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn10] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN10] add_channel (tagname, tagchannel) elif tag [c4d.compositingtag_enablechn11] == 1: tagname = all_op.GetName () tagchannel = tag[c4d.COMPOSITINGTAG_IDCHN11] add_channel (tagname, tagchannel) all_op = GetNextObject (all_op) c4d.EventAdd() if __name__=='__main__': main() |
Hey, this is a nice script, but you have syntax errors:
“on op.GetUp = () ” probably missing “=” after on?
“[c4d.compositingtag_enablechn1]” ID should be all caps
I modified this script to work on selected tags only, will credit your code and share for free, hope it is OK with you?
Cheers,
Sandi Dolšak
would you please give info how to use that script thank you
Don’t work with c4d R16
File “‘scriptmanager'”, line 9
on op.GetUp = ()
^
SyntaxError: invalid syntax