On 25/06/2015 at 02:18, xxxxxxxx wrote:
Hi Community,
i just started with python (i'm a total n00b and no mathematical genius ;)) and i have a logical problem with my script. maybe someone can help me out _<_img src="http://www.c4dcafe.com/ipb/uploads/emoticons/default_smile.gif" border="0" alt=":)" title=":)" /_>_
insert_light **creates a null_object with a light as a child. The null gets named Light.1, Light.2, Light.3...
insert_scene **creates a null_object with a cube as a child. The null gets named Scene.1, Scene.2, Scene.3...
the problem with my script is, that insert_light() and insert_scene() create Nulls like
Light.1
Scene.2
Light.3
Scene.4
But I want it like
Light.1
Scene.1
Light.2
Scene.2
How can i rename the nulls with the same child sequentially and not all nulls? Can anyone help me with this?
Thanks! Martin
--------------------------------------------------------------------------
import c4d
from c4d import gui
#Welcome to the world of Python
def insert_light() :
doc.InsertObject(c4d.BaseObject(c4d.Onull))
doc.InsertObject(c4d.BaseObject(c4d.Olight))
parent = doc.SearchObject("Null")
child = doc.SearchObject("Light")
child.InsertUnder(parent)
ObjCount = doc.GetObjects()
OTypCount = 0
for i in ObjCount:
if child.GetType() == 5102 and i.GetType() == 5140:
OTypCount = OTypCount + 1
parent.SetName("Light."+ str(OTypCount))
c4d.EventAdd()
def insert_scene() :
doc.InsertObject(c4d.BaseObject(c4d.Onull))
doc.InsertObject(c4d.BaseObject(c4d.Ocube))
parent = doc.SearchObject("Null")
child = doc.SearchObject("Cube")
child.InsertUnder(parent)
ObjCount = doc.GetObjects()
OTypCount = 0
for i in ObjCount:
if child.GetType() == 5159 and i.GetType() == 5140:
OTypCount = OTypCount + 1
parent.SetName("Scene."+ str(OTypCount))
c4d.EventAdd()
if __name__=='__main__':
insert_light()
insert_scene()