THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/12/2012 at 15:31, xxxxxxxx wrote:
Originally posted by xxxxxxxx
For the looping through all objects, would I check for the name attribute if I'm making a replicator that has an incremental naming system?
i meant more a property / type driven selection. the most basic element of all c4d objects,
the c4d.Atom, provides a GetType() / CheckType() method with which you could make some
basic decisons. Is a material, is it a shader, is polygon object or is a MoGraph Shader Effector ?
if (myObject.GetType() == c4d.Onull) :
doSomething()
on the other hand there are the properties of the object (the settings shown in the attribute
manager) which you access with the bracket syntax. this goes down to the the c4d.BaseContainer
and c4d.DescID system.
while (myObject[myBooleanProperty]) :
On your specific task - it is quite difficult to understand what you want to achieve (at least for me),
it sounds a bit like some rigging stuff. however, using object names as object identificator is really
unsafe and should be avoided at all cost. for massive object references use InExcludeData which is
named a bit misleading, because it is just a list of object (GeListNode) links.
if this all doesn't help, please tell us more precisely what you want to do and where the objects
are coming from. when you import some super massive rig from somewhere the user will have to
do some mapping (LinkBox) or you will have to rely un propper naming. when you create the
objects yourself just use some form reference as nikklas wrote.
last but not least some very basic but commented example:
import c4d
def main() :
# a list to store our objects
myObjectList = []
# create some objeccts
for n in range(10) :
# a parametric cube
myCube = c4d.BaseObject(c4d.Ocube)
# a display tag
myTag = c4d.BaseTag(c4d.Tdisplay)
# attach the tag to the cube
myCube.InsertTag(myTag)
# add both to a local list
myObjectList.append(myCube)
myObjectList.append(myTag)
# insert cube with the tag into the document
doc.InsertObject(myCube)
# update the gui, the objects are now in the document
c4d.EventAdd()
# from somewehre else we want to access our objects and we have
# this list, but we do not know that it contains cube and display tags in a
# alternating order, we only know it is a list of c4d.Atoms ,which might also
# contain other stuff. so we loop through it and check every object.
# some initial vector for the cube size
size = c4d.Vector (25,25,25)
# loop through the data
for n in myObjectList:
# if it is a cube set its size and increment the size by factor 1.1
if (n.GetType() == c4d.Ocube) :
n[c4d.PRIM_CUBE_LEN] = size
size *= 1.1
# if it is a display tag activate the force shading mode and set it to lines
if (n.GetType() == c4d.Tdisplay) :
n[c4d.DISPLAYTAG_AFFECT_DISPLAYMODE] = True
n[c4d.DISPLAYTAG_SDISPLAYMODE] = 6
if __name__=='__main__':
main()
ps : just to be clear, this is a working script example .