@blastframe Ok was able to retrofit your version to get what I wanted, a bit of guesswork in here, but got the result im after lol
import c4d
from c4d import gui
def createInstance():
obj = op.GetDown()
inst = c4d.BaseObject(c4d.Oinstance) # created Instance with Base Object
inst[c4d.INSTANCEOBJECT_LINK] = obj # set Instance's reference link
# set the name using the object passed to the function
inst[c4d.ID_BASELIST_NAME] = "%s Instance"%obj[c4d.ID_BASELIST_NAME]
return inst # return the Instance instance
def AddLongDataType(obj): # create User Data Container named Picker
if obj is None: return
bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)
bc[c4d.DESC_NAME] = "Picker"
doc.AddUndo(c4d.UNDO_CHANGE, obj)
obj.AddUserData(bc)
c4d.EventAdd()
def setQuickTab(obj, inst, data): # change User Date container to type Cycle, populate with Children Names
descid = data[0][0]
bc = data[0][1]
children = obj.GetChildren()
# Build new cycle options container dynamically
cycle = c4d.BaseContainer()
for i,child in enumerate(children):
cycle.SetData(i, child.GetName())
bc[c4d.DESC_CYCLE] = cycle
doc.AddUndo(c4d.UNDO_CHANGE, obj)
# Set modified description data container
inst.SetUserDataContainer(descid, bc)
def main(doc):
obj = doc.GetActiveObject()
if (obj == None):
gui.MessageDialog("Please select the Root of the Assets you wish to Instance.")
return
doc.StartUndo()
inst = createInstance()
doc.InsertObject(inst)
AddLongDataType(inst)
data = inst.GetUserDataContainer()
setQuickTab(obj, inst, data)
doc.AddUndo(c4d.UNDO_NEW, inst)
doc.EndUndo()
c4d.EventAdd()
if __name__=='__main__':
main(doc)