get all objects of type x



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/07/2009 at 10:04, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.6+ 
    Platform:   Windows  ; Mac  ;  
    Language(s) :     C++  ;

    ---------
    Hi,

    is there a nice way to get all objects of a certain type in the scene, like all atomArrays for example ?

    There must be something more efficient then getFirst() and traversing with getDown() and getNext() and so on..

    any hints apprecciated ;-)

    cheers,
    Daniel



  • 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.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/07/2009 at 12:06, xxxxxxxx wrote:

    I'm a coffeeboy so I don't know if there is any difference,
    but for quick scripts I use the SelectAllObjectsCommand and then
    use SearchNext(BIT_AOBJ) starting from the top.
    It search "linear" thru the OM as far as I can tell.

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/07/2009 at 15:20, xxxxxxxx wrote:

    Unfortunately, there is no SearchNext() in C++. SearchObject() searches by object name only. Curiously, there is a FindSkyObject(doc) in the SDK. It is the only *direct* object find that I can, well, find. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/07/2009 at 23:37, xxxxxxxx wrote:

    thanks guys,

    i'll write it as slim as i can then, and see how that goes.

    cheers,
    Daniel


Log in to reply