On 01/10/2013 at 02:38, xxxxxxxx wrote:
Hello everybody. Below I have a very simplified version of what I'm trying to create.
The simplified code:
Runs a loop to get all of the user data and prints it to the console
Creates a new user data object (just lifted that straight from the documentation)
Runs the same loop again and print to the console again.
The results in the console are identical and I have to run the script again to be able to access the new userdata.
Import c4d
def main() :
obj = doc.SearchObject("Null")
ud = obj.GetUserDataContainer()
for id, bc in ud:
print id, bc[1] # The readout on console shows Test data 1 and Test data 2
bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG) # Create default container
bc[c4d.DESC_NAME] = "Test data 3" # Rename the entry
element = obj.AddUserData(bc) # Add userdata container
obj[element] = 0 # Assign a value
c4d.EventAdd() # Update
for id, bc in ud:
print id, bc[1] #The readout on console shows Test data 1 and Test data 2 but no sign of Test data 3
if __name__=='__main__':
main()
I know I can set all of the parameters before I create the userdata, however what I intend to do is create a group and then clone some userdata and nest it in the group without having to run the script twice.
My question is: Can I access newly created/cloned userdata within a single execution of a script?
Any help is much appreciated.
Thanks
Adam