On 27/01/2016 at 02:53, xxxxxxxx wrote:
Hello everyone :)
I'm stuck with a little Problem and it would be very great if someone could help me out on this.
If you press a button in my plugin it creates a null-object with the name (for example) CAMERA.1. If you press it again it creates CAMERA.2, CAMERA.3 and so on. This works fine as long one does not delete one of the objects. Then the last incremental number doesn't match anymore.
If you create Objects in Cinema 4D, for example Null.1, Null.2, Null.3, Null.4 and you delete Null.2, Cinema will create the object with the missing name Null.2
I'm kind of a python beginner, and i would be very happy for any kind of logical approaches.
here is the part of the function for renaming the created Nullobject
otype = "CAMERA"
master = doc.SearchObject(Pluginname)
parent = doc.SearchObject("Null")
ObjCount = master.GetChildren()
OTypCount = 0
for i in ObjCount:
if i.GetDown() and i.GetType() == 5140:
if i.GetDown().GetType() == ID:
OTypCount = OTypCount + 1
name = str(otype)+"."+ str(OTypCount)