Access the Object List Xpresso Node for Python Iteration
-
Hi,
Is there a way to access Object List Xpresso Node for Python Iteration?
I have trouble finding information in the documentation. It does not have ac4d.InstanceData
compared with thec4d.InExcludeData
You can see an illustration of the problem here:
https://www.dropbox.com/s/s2zfd45ofz4rcpd/c4d193_access_object_list_node_for_iteration.jpg?dl=0Is there a way around this?
Thank you
-
Hi,
first of all: you are passing the node, not the
Iteration List
parameter in your expresso graph. So you have to access that parameter in your Python node (obj_list[ID_OF_THE_ITERATIONLIST_PARAMETER]
). Secondly, I am not one hundred percent sure, but the data type of the of theIteration List
parameter should beInExcludeData
. This type (unfortunately) does not implement__iter__()
, so you cannot treat it like an iterator. See the docs on how to access entries on that data type.Cheers
zipit -
@zipit
Thanks for the response.
Unfortunately, it's not an
InExcludeData
. The port does not connect (i.e it grays out rather than a green line).I debugged with the
type(obj_list)
and interestingly it is ac4d.BaseObject
.
It performs iteration even without a for loop in the code.Is there a way to force the output to be in a list?
My previous code is in
InExcludeData
but it uses a selection object, which makes it hard to navigate to the actual selection list to be used for animation.You can see the sample file here:
Thank you for looking at my problem:
https://www.dropbox.com/s/ia73prlw9mr00ik/c4d193_access_object_list_node_for_iteration.c4d?dl=0 -
Hi,
I should have opened Cinema for my initial answer. The
Object List
node returns an object from itsIteration List
parameter on theInstance
port (and your Python node is called multiple times, once for each object in the list). So you have to either fashion your Python node in such way, that it is working on single nodes or add anIncluedeExcludeData
user-data element to your graph and pass that element.Cheers
zipit -
@zipit
Thanks for the response.
RE: So you have to either fashion your Python node in such way, that it is working on single nodes
I'm not sure I understand. Are you suggesting not to useObject List
node and just use individual nodes plugged into a Python node? If so, I have done that before and it clutters the node editor. I would prefer just to use theObject List
and access it as a list forfor loop
.RE: add an IncluedeExcludeData user-data element to your graph and pass that element.
Sorry. I don't understand. The Object List returns an Instance Data (or maybe a BaseObject), which does not connect to aincluedeExcludeData user-data element
correct me if I'm wrong. -
The ObjectList is already effectively an iterator over the contained objects. On each frame to evaluate the 'instance' port will provide the 1st, then 2nd, then 3rd, etc. object to the downstream node.
-
Hello,
As @wuzelwazel said, the ObjectList is an iterator. It will execute your python node for every object of its list.
You can add a UserData to your Python node (as to any object) and use that as your objects list entry to manage yourself the iteration and forget the ObjectList node.
Did i miss something here ?
Cheers,
Manuel -
@wuzelwazel and @m_magalhaes
Thanks for the response. I understand that the ObjectList is an iterator.
But I want to perform my own iteration with thefor loop
.I want it to be read in the Python node as a list (i.e. before the iteration).
This is in the previous post but it still applies (i.e. prints an object rather than a list)
https://www.dropbox.com/s/ia73prlw9mr00ik/c4d193_access_object_list_node_for_iteration.c4d?dl=0RE: You can add a UserData to your Python node (as to any object) and use that as your objects list entry to manage yourself the iteration and forget the ObjectList node.
I'm not sure I understand. My python is an expresso node. And not a python tag or object. So I can't necessarily add a userdata. -
hello,
Does using the object list iterator is mandatory or not ?
@bentraje said in Access the Object List Xpresso Node for Python Iteration:
I'm not sure I understand. My python is an expresso node. And not a python tag or object. So I can't necessarily add a userdata.
you can add userdata to xpresso node, juste like any object.
you can see in this file that i can use UserData to create my own iterator python_userdata.c4d
cheers,
Manuel -
@m_magalhaes
RE: Does using the object list iterator is mandatory or not ?
For this one, it kinda is since the whole code base rest on thefor loop
section.RE: you can see in this file that i can use UserData
Thanks for the clarification. I see what you mean now. It works on my use case.Have a great day ahead!