Active Objects - Change attributes

On 03/06/2017 at 19:51, xxxxxxxx wrote:


I'm trying to change some attributes from a different objects at the same time, in this case I'm trying to change "use color" and "display color" attribute for testing with that.

When I use the code with one object works fine but if the object have some children objects the console shows me "IndexError: list assignment index out of range" but I don't understand why, because I've use a GetActiveObjects with a c4d.GetActiveObject_Children flag.

I need to get the entire objects selection with other way maybe? Here is the code:

import c4d
from c4d import gui
def geo_color() :
    doc = c4d.documents.GetActiveDocument()
    #activeObject = doc.GetActiveObject()
    activeObject = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
    #List of selected objects
    print activeObject
    #geo color actions
    #cdlg = c4d.gui.ColorDialog(1)
    #update scene
if __name__=='__main__':


On 04/06/2017 at 00:10, xxxxxxxx wrote:

Get activeObjects return you a list of BaseList2D So you have to iterate throught this list basicly do

import c4d
def geo_color() :
    doc = c4d.documents.GetActiveDocument()
    activeObjects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
    #If we get nothing select we quit
    if not activeObjects:
    #Loop through the content of activeObjects and call each element of activeObjects obj
    #obj are BaseList2D so we can set their value
    for obj in activeObjects:
        obj[c4d.ID_BASEOBJECT_USECOLOR] = 2
    # update scene
if __name__ == '__main__':

On 12/06/2017 at 14:54, xxxxxxxx wrote:

Thanks! That's make sense.