There you go - made by Per Anders Edwards :)
import c4d
from c4d import gui
# Welcome to the world of Python
# Recursively executes a function
def DoRecursive(obj, function, **args):
while obj:
function(obj, args)
if obj.GetDown() != None:
DoRecursive(obj.GetDown(), function, **args)
obj = obj.GetNext()
def ColorFunction(obj, args):
objColor = obj[c4d.ID_BASEOBJECT_COLOR]
if objColor == args["color"] and not obj.GetBit(c4d.BIT_ACTIVE):
doc.AddUndo(c4d.UNDOTYPE_BITS, obj)
obj.SetBit(c4d.BIT_ACTIVE)
def main():
if not op:
return
doc.StartUndo()
searchColor = op[c4d.ID_BASEOBJECT_COLOR]
firstObject = doc.GetFirstObject()
DoRecursive(firstObject, ColorFunction, color = searchColor)
doc.EndUndo()
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()