On 07/05/2015 at 07:23, xxxxxxxx wrote:
Quicktab dynamically filled:
Got it to work and thought, I share...
I call this as a user script and not inside a Python tag since the number of children does not change often during projects. I'll eventually use a button and the message() function in the userdata but that seems to be too much of a distraction here.
Thanks again for the input.
----------------------------------------------------
import c4d
from c4d import gui
def setQuickTab(obj, data) :
descid = data[0][0]
bc = data[0][1]
# Build new cycle options container static
#cycle = c4d.BaseContainer()
#cycle[0] = "Tab 1"
#cycle[1] = "Tab 2"
#cycle[2] = "Tab 3"
#cycle[3] = "Tab 4"
#cycle[4] = "Tab 5"
# Get the number of child objects
parent = doc.SearchObject("UD container") # could be any different object
count = len(parent.GetChildren())
print "count: ", count
# Build new cycle options container dynamically
cycle = c4d.BaseContainer()
for i in range (0,count) :
caption = "child " + str(i+1)
cycle.SetData(i, caption)
bc[c4d.DESC_CYCLE] = cycle
# Set modified description data container
obj.SetUserDataContainer(descid, bc)
# Notify Cinema 4D for changes
c4d.EventAdd()
def main() :
obj = doc.SearchObject("UD container")
data = obj.GetUserDataContainer()
setQuickTab(obj, data)
if __name__=='__main__':
main()