On 12/06/2015 at 16:10, xxxxxxxx wrote:
Hi,
Is it possible to detect if an object has a Generator checkmark? I can detect if a generator is unchecked, but for objects that don't have a checkmark (like a Null) they always return true when I try:
generator_on = obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG]
I'm currently checking objects against a manually generated list of exempted types, but I'd like to know if there's a better way, because if I forget to include a type, or a new object type is added to cinema, my code will break:
def is_muted(obj) :
"""Return True if object is hidden in editor, renderer, and disabled."""
if debug:
print "is_muted(%s)" % (obj.GetName())
if (obj is None) or (not obj.IsAlive()) :
return
#Determine visibility based on `Visible in Editor/Renderer` not set to `Off`
visible_in_editor = (obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] != 1)
visible_in_render = (obj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] != 1)
if visible_in_editor or visible_in_render:
if debug:
print "Visible in editor/renderer", obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR]
return False
#If the generator flag is on, and it's not a special type, the object isn't mute.
generate = obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG]
if generate:
if debug:
print "Generate is on"
obj_type = obj.GetType()
exempted_types = [c4d.Opolygon,
c4d.Onull,
c4d.Ospline,
c4d.Ocamera,
c4d.Ofloor,
c4d.Osky,
c4d.Oenvironment,
c4d.Oforeground,
c4d.Obackground,
c4d.Ojoint,
]
if obj_type not in exempted_types:
return False
return True