FindObject() within a parent?
-
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
-
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 -
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!