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

    FindObject() within a parent?

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 290 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 25/03/2010 at 09:09, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11.5 
      Platform:      Mac OSX  ; 
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      I am looking for a way of searching for an object by name, but only within a certain branch of the hierarchy.

      e.g. There are two Nulls, Null1 and Null2. Within Null1 there is an object called Object1 , and I want to search inside Null2 to see if IT also has an object called Object1.

      However, if Null1 is higher up in the Object window, then it will return Object1 from within Null1 , and won't get as far as looking inside Null2.

      Also, is there a way to identify all of an object's children (and subchildren and subsubchildren etc etc.) and put them in array.

      Probably really stupid questions or the wrong way of approaching it or something, but any help at all would be greatly appreciated!

      Thanks

      Peth

      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 30/03/2010 at 07:39, xxxxxxxx wrote:

        You have to browse manually through the hierarchy and check the names.

        here an example:

          
        BrowseHierarchy(obj,name)  
        {  
          while (obj)  
          {  
              if (obj->GetName() == name)  
              {  
                  //if object name matches search name return the obj  
                  return obj;  
              }  
          
              //check the recursion  
              var child = BrowseHierarchy(obj->GetDown(),name);  
              if (child) return child;  
          
              obj = obj->GetNext();  
          }  
          
          return NULL;  
        }  
          
        FindChild(obj,name)  
        {  
          if (obj)  
          {  
              // if obj is valid go down one step in hierarchy and browse  
              return BrowseHierarchy(obj->GetDown(),name);  
          }  
        }  
          
        main(doc,op)  
        {  
          var child = FindChild(doc->GetActiveObject(),"Plane");  
          
          if (child) println(child->GetName());  
          else println("not found");  
        }  
        

        cheers,
        Matthias

        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 06/04/2010 at 07:08, xxxxxxxx wrote:

          Brilliant, that's exactly what I needed.

          Thanks very much for your help again Matthias!

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