Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    get all objects of type x

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 409 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post