could not find port value?
-
On 30/05/2013 at 08:15, xxxxxxxx wrote:
I have this little piece of code inside of a python node in xpresso:
def main() : global Output1 global Output2 def selection(minimum, maximum) : x=0 while x < Input1: if x >= minimum and x <= maximum: Output1 = x Output2 = 1 else: Output1 = x Output2 = 0 x += 1 selection(3,10)
I get the error "Could not find port value for 'Output1' in node 'python'.
it seems like it should work. If I print output 1 and 2 to console I get the correct value but its like its not feeding the info to the next node. Is it because its being iterated on each frame? -
On 30/05/2013 at 09:55, xxxxxxxx wrote:
1. when Input1 is smaller then zero the output ports will never be written. always return a
default value if you could not compute a proper value.
2. are you sure that output 1 and 2 have the correct port type ? -
On 30/05/2013 at 10:11, xxxxxxxx wrote:
1. The input currently is at 30, and has always been >= zero when testing
2. I tried interger and float for Output1, same thing?
If I take away everything and just say Output = 5, for example, it works as expected, but not inside the loop.
Seems like it should work no problemI saw someone used this code when having a similar issue but wasn't able to get it to work for me:
exec CODE in globals(), locals()
-
On 30/05/2013 at 10:25, xxxxxxxx wrote:
1. you still exceed cut the values at some point. placing such loose ends in your code is not good.
2. might also be a scope problem, try something like that.def main() : global Output1 global Output2 def selection(minimum, maximum) : a, b, x = c4d.NOTOK , c4d.NOTOK, 0 while x < Input1: if x >= minimum and x <= maximum: a = x b = 1 else: a = x b = 0 x +=1 return a, b Output1, Output2 = selection(3,10)
-
On 30/05/2013 at 11:44, xxxxxxxx wrote:
Thanks for the help LD, that did stop the error. However it only returns the value of the last number in the iteration. Trying to get it to set either a value of 1 or 0 to every object per frame. I tried messing with it to make it work but no luck. I have it working with without the python node, but thought code would be much easier/cleaner way to do it. Guess i'll just do without the py node for now, but thanks anyway.
-
On 30/05/2013 at 13:03, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Thanks for the help LD, that did stop the error. However it only returns the value of the last number in the iteration. Trying to get it to set either a value of 1 or 0 to every object per frame. I tried messing with it to make it work but no luck. I have it working with without the python node, but thought code would be much easier/cleaner way to do it. Guess i'll just do without the py node for now, but thanks anyway.
I am not sure if I do understand correctly what you are trying to do, but Xpresso does neither
support arrays nor can scripting nodes (coffee / python) work as an iterator on its own. There
are three ways to work your way around that.1. Make your python node compute a step in a loop. As an example xpresso setup for your
object problem (you just need an iterator node, in that case the object list node) :|--- Loop called n times per pass -------------------------------->
ObjectListNode.instance >> input0.PythonNode.result >> result.SomeNodein the same xpresso setup /group :
|--- Only called once per pass -------------->
SomeNode.out >> in.SomeNode.out >> in.SomeNode2. You can also use a link port to cheat your way around the no array restriction of xpresso.
simply pass a linkable object derived from BaseList2D which does allow you store data in
a array like fashion. A PointObject (spline, PolygonObject) is a good candidate for that.3. Simply keep everything inside the python node and do not use output ports. Or in other
words do all the computing inside the python node. -
On 30/05/2013 at 13:23, xxxxxxxx wrote:
That must be the hang up, I didn't know you couldn't use the python node as an iterator in Xpresso. Good to know. Also some nice work around options you've given too! The Xpresso setup was pretty easy anyway, just thought it would be a simple python node exercise I could try. I'll give these options a look, the first one seems the most doable for my level. Thanks again for all your help! You rock!