On 15/03/2017 at 05:48, xxxxxxxx wrote:
that's not going to work that way. An iterator node in Xpresso works differently and you can't imitated something like that via a Python Script node. An iterator gets executed several times per evaluation of the Xpresso setup (the Python Script node only once) and thus triggers re-execution of connected nodes.
Another problem you are facing is, that you can not return a list of objects. So in your code example, the Python script gets executed, it iterates through the for-loop, assigning the variable "obj" successively with different child objects and then in the end the variable "obj" gets assigned to the output, which then is the last child in the hierarchy.
By the way, GetChildren() does only return the next level of children (that's what the docs mean by "no grandchild"), which is something the Hierarchy node delivers in its default setup. If you want all the children of a more complex hierarchy, you'd need something like the functionality of GetActiveObjects() with GETACTIVEOBJECTFLAGS_CHILDREN flag, but that of cause can not be used in an Xpresso Python node. So you will have to walk the hierarchy yourself.
My suggestion would be to build the following:
Have a Python Script node with a link input (the input ("parentObj" in below code) is connected to your parent object) and an output port of type "In-Exclusion" ("InExData" in below code). This output port gets connected to an ObjectList Iterator node with an "Iteration List" input. The "Instance" output port of this ObjectList iterator will deliver the objects you want.
In the Python Script node use the following code:
def AddHierarchyToInEx(obj, inex) :
if obj is None:
while obj is not None:
obj = obj.GetNext()
def main() :
InExData = c4d.InExcludeData()
if parentObj is None:
Edit: Changed code after below discussion. Before InExData was passed as a list to AddHierarchyToInEx().