find out if generator object? (in case of a Field object)
-
hi,
there is an old thread about this question:
https://developers.maxon.net/forum/topic/6722/7354_find-out-if-generator-object
with this conclusion :if obj.GetInfo() & c4d.OBJECT_GENERATOR: print "a generator" else: print "not a generator"
now i stumbled onto that Fields (eg. a Linear Field) do NOT qualify as generators in this test,
but they DO have the green (enabled) checkmark that can be ticked on and off.is this a bug in the field objects ?
or how can one find out if an object has the green checkmark or not ?best, index
-
The green tick/red cross only indicates if an object is enabled or not. You can see it with deformers, fields, primitives (which are generators anyway), other generators such as the cloner or extrude, etc. The tick does NOT show that the object is a generator. You only see it with objects whose actions can be enabled or disabled, so you won't see it with polygon objects or things such as the floor object.
To get the status of the green tick for objects which have it, use GetDeformMode().
(Edit) I've never used it, but if you call obj.GetInfo() and test for the flag OBJECT_HASDEFORMMODE, if that flag is present then it seems that the object does have the green tick. This could be useful when looking at objects which aren't generators, etc. but still have that tick.
Steve
-
Hello @indexofrefraction,
Thank you for reaching out to us. Here seem to mix up two questions, let me split them up.
How to find out if something has a green check mark?
The green checkmark and its counterpart the red cross are just an alternative way to set
ID_BASEOBJECT_GENERATOR_FLAG
, i.e., the enabled state of an object.The caveat is however that this parameter is part of the BaseObject Description model, i.e., literally every object has that parameter. It is just that some object types hide and restrict write access to it. So, this applies:
# Get/set the generator flag of an object where we know that it has that GUI, can be disabled. state: bool = op[c4d.ID_BASEOBJECT_GENERATOR_FLAG] op[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = not state def CanDisable(obj: c4d.BaseObject) -> bool: """Tests if #obj can be disabled, i.e., if it has the "check mark GUI". """ # An object which is disabled always has that GUI. if not obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG]: return True # Attempt to disable the object. obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = False # The object refused being disabled, it hides that GUI. if obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG]: return False # The object let us write the state, reinstate the previous state and return #True obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = True return True # Figure out if something lets us write to #ID_BASEOBJECT_GENERATOR_FLAG, i.e., if it can be # disabled. print(CanDisable(op))
What is a generator?
But the underlying question is: What qualifies as a generator? We have to remind ourself that modern day Cinema 4D (V5 up 2025.1.0) is a 27 years old software project. There is bound to be some terminological noise and inconsistency how flags are set/interpreted because when there is one thing developers love to do, then it is bending the rules
.
The OBJECT flags do exist to enable API features when an
ObjectData
plugin is registered.BaseList2D::GetInfo
just exposes that registration data and is not meant as a user facing classification of objects. Because whichOBJECT
flags are passed and which kind of object plugin registration function is called, then determines how Cinema 4D operates that object in the scene graph.OBJECT_GENERATOR
in combination withIS_SPLINE
for example makes it so that Cinema 4D callsObjectData::GetVirtualObjects
orObjectData::GetContour
, the methods which implement a polygon or spline object generator.But over the time, our developers got creative, and there are now objects which act both as objects and splines, objects can (sort of) act as tags, and many things more. And then there are of course things like null objects, lights, cameras and more, which escape the pattern "poly generator, spline generator, point deformer, or particle deformer" entirely. When interpreted practically, I would classify everything as a generator that has a cache that is not a null object. You can read more about our object model here.
Last but not least, when you just want to find out if something is a field, you can just test for
OBJECT_FIELDOBJECT
. But just as forOBJECT_GENERATOR
, some things might bend on a technical level the rules of what a field is and what not, as these are not classification flags but API features enabling flags.Cheers,
Ferdinand -
hey thanks for taking so much time for this ...
for me it is only important to know if the gui element exists on the object...
and its kind of awkward to have to change its state to figure that out.
i fear that will trigger lots of stuff and slow down scenes even more
(i have to check for many objects in complex scenes, and i can't know what obj types that are)is there no other way than disabling and re-enabling the object?
in my experience c4d is very sensitive to object status changes and its easy to hog it down and make a scene unresponsive.
EDIT : searching the objects Descriptions it is possible to find "Enable", but as mentioned Null Object has it too, it is just hidden.
It would be very nice to be able to check if it is the right "Enabled" (there could be more) and if it is visible in the GUI. -
Hey @indexofrefraction,
it seems I was a bit unclear in what I meant.
- Your question (and also @spedler answer) are incorrect in that they assume 'green check mark means that an object has the flag
OBJECT_GENERATOR
'. There are many exceptions to this, as for example deformers, cameras, and lights (at least the old standard renderer ones). - The green check mark is expressed by
ID_BASEOBJECT_GENERATOR_FLAG
and all objects have that parameter as it is part of the object base description. It is just that some object types hide it, and restrict write access to it. But you can always attempt to write to it. - Your whole approach does not make too much sense (at least without further explanation). As always, we do not expose GUI details, but the data behind it - which in this case is
ID_BASEOBJECT_GENERATOR_FLAG
. You can set this flag blindly on any object, some objects will just refuse write operations which set this toFalse
(as they are object which cannot be disabled).
And, yes, changing a parameter makes an object data dirty which entails Cinema 4D rebuilding the scene graph. But that was not how my code example was meant. It just demonstrates how this works. When you want to disable an object, you can just attempt to do it, and when it fails, you know that the object does not support being disabled. This whole of approach of "I want to know if an object has a green check mark" is wrong.
You could clone a node to set the parameter without having changes affect the scene graph. But cloning nodes can also be a quite expensive operation. Looking into the description could be another way, you would have to get the description container for
ID_BASEOBJECT_GENERATOR_FLAG
and then check ifDESC_HIDE
is set. That is at least how I would expect that they have realized that.Cheers,
Ferdinand - Your question (and also @spedler answer) are incorrect in that they assume 'green check mark means that an object has the flag
-
hi, i came up with this now...
def hasGenFlag(op): description = op.GetDescription(c4d.DESCFLAGS_DESC_NONE) if description: bc = description.GetParameter(c4d.ID_BASEOBJECT_GENERATOR_FLAG) if bc: return not bc[c4d.DESC_HIDE] return False
also its clear that "Generator" is a wide definition which doesn't match the Green Checkmark / Enabled GUI Element.
in this sense the topic title is wrong bc i was just searching for a way to distinct objects having this GUI element from others which don't.