THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/07/2009 at 11:39, xxxxxxxx wrote:
Even if there was a built-in way, it would do exactly the same thing (this is how BaseObject::GetTag() works from what I've been told) - recurse through the scene to find the objects of the type desired. The way Cinema 4D stores the objects - as list trees of BaseList2Ds under the BaseDocument doesn't lend to quicker determinations. If you must do it often, you may want to set up an AtomArray to hold the objects of the type required but this will need to be maintained (for new objects added and being aware that an index may be NULL if the object has been removed from the document). If you need to fill it each time, then just remember to AtomArray::Flush() before each use.
The speed of the recursion is not too bad if you take care to construct the recursive function well: don't declare variables inside a loop, keep function arguments to four or less. Also, if possible, it is more expedient to collect objects into an AtomArray and process them linearly afterwards than to do the processing in or from the recursive function itself. The reason is that recursivity incurs overhead such as the stack callbacks, unwinding, and all of the data needed therein. So, an efficient recursion to collect and a single loop to process.