AWS Thinkbox Discussion Forums

Get Object from class instance?

I tried using:

For o in objects where classof o == xMeshLoader

However we missed quite a few objects. Bobo’s:

(getClassInstances XMeshLoader)

Got everything, but it has no concept of object in the scene. Is there a way to take a class instance and figure out what node/object it is in the scene graph for renaming, selecting etc?

Yes, you can use the following function to get the nodes associated with the class instance: refs.dependentNodes

The real problem with classof o is that the class is mutable and if you have a modifier on the stack, the object might appear as an EditableMesh instead.
For example, create an XMesh Loader, select it and run:

classof $ -->XMeshLoader addModifier $ (Bend()) -->OK classof $ -->Editable_mesh
This is why a modified XMesh Loader might not get collected by

theLoaders = (for o in objects where classof o == XMeshLoader collect o)

But if you ask for the base object instead…

classof $.baseobject -->XMeshLoader
In other words,

theLoaders = (for o in objects where classof o.baseobject == XMeshLoader collect o)

This should find any XMesh Loader, with or without modifiers!

Nice, very good to know!

Privacy | Site terms | Cookie preferences