Hello everyone!
I`m noobie and working on simple script that should generate on selected layers Redshift Object tag with checked Object ID Override. Also I need to make uniqe Object ID numbers by adding 1 to each tag.
Problem: When I make loop through tags and try to increase Object ID parameters by 1 (I need 1, 2, 3,...) it pass all the tags exept the last and make the last tag Object ID parameter equal to objects quantity (9 in my case)
- How to increase Object ID parameters for each tags with uniqe data from 1 to {tags quantity}?
- How to improve this code?
import c4d
from c4d import gui
def main():
doc.StartUndo()
selection = doc.GetSelection()
collectedObjects = []
if selection:
for s in selection:
collectedObjects.append(s)
else:
c4d.gui.MessageDialog('Please choose objects')
for s in collectedObjects:
tag = c4d.BaseTag(1036222)
tag[c4d.REDSHIFT_OBJECT_OBJECTID_OVERRIDE] = True
s.InsertTag(tag)
doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
for tags in range(len(collectedObjects)):
tag[c4d.REDSHIFT_OBJECT_OBJECTID_ID] += 1
doc.EndUndo()
if __name__=='__main__':
c4d.CallCommand(13957)
main()
c4d.EventAdd()
Thank you for your attention!