Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi,
Is there a way to get the "next" object of doc.SearchObject() method. As I understand, if there are two objects name cube. The method will retrieve first cube in the outliner. Is there a way to get the next cube object?
doc.SearchObject()
cube
My use case is this:
I guess I can do this with the traversing objects hierarchy code provided by the plugincafe. Storing each object name and comparing them with each other.
But it would be nice if I can just do this with doc.SearchObject so I can shorten the logic.
doc.SearchObject
Regards, Ben
Hi unfortunately there is nothing built-in so you have to iterate over the scene.
import c4d def HierarchyIterator(obj): while obj: yield obj for opChild in HierarchyIterator(obj.GetDown()): yield opChild obj = obj.GetNext() def main(): names = set() for obj in HierarchyIterator(doc.GetFirstObject()): objName = obj.GetName() if objName not in names: names.add(objName) else: print("{0} Is already present".format(objName)) if __name__=='__main__': main()
Cheers, Maxime.
@m_adam
Ah gotcha. Thanks for the confirmation and the sample code.