Error: "Infinite recursion in evaluation"

   10566   8   1
User Avatar
Member
52 posts
Joined: June 2009
Offline
Hi guys,

I have written a python node. Sometimes it gives me an error stating that “Infinite recursion in evaluation”. What does it mean and how to overcome this..?

Cheers.
User Avatar
Member
2199 posts
Joined: July 2005
Online
That usually means something is being referenced that then references the original thing back again, thus creating recursion.
Without seeing the code or how the hip file is setup it's next to impossible to say what is causing it in your case. Can you post an example.
The trick is finding just the right hammer for every screw
User Avatar
Member
52 posts
Joined: June 2009
Offline
Hi Simon,

I hav uploaded the hip file. Try this n help me out.

Cheers.

Attachments:
road.zip (7.2 KB)

User Avatar
Member
2199 posts
Joined: July 2005
Online
I'm not sure you can use that selectPositions inside a sop, it looks like its designed to be used from a toolbar script only.

Apart from that you need to change your definition of “c” to

c = hou.pwd().parm(“coord”)
The trick is finding just the right hammer for every screw
User Avatar
Member
52 posts
Joined: June 2009
Offline
Cheers. So Simon, can you telme how can i select the positions and store it in a python node..?

Thanks in advance.
User Avatar
Member
2199 posts
Joined: July 2005
Online
unfortunately I've not tried that in a python node.

Maybe you need to create a toolbar script and a python node and use the toolbar script to pass the result to the node…

Maybe someone from Sesi can suggest the correct way to do this.
The trick is finding just the right hammer for every screw
User Avatar
Member
52 posts
Joined: June 2009
Offline
OK. Thanks a lot Simon.

Cheers.
User Avatar
Member
1906 posts
Joined: Nov. 2006
Offline
The real source of the error is the fact that you are attempting multiple times to set a parameter on the node while the node cooks. This can lead to a lot of problems because changing the parameters can cause recooking, hence the infinite part. Also, as I mentioned in the other thread and Simon sort of touched on here is that having a selection function in the cooking code is BAD. Every time you do anything you are forced to reselect your positions. Also, assuming the code can be made to cook, the way you are attempting to join the position results is also going to give you bogus/useless results. It's basically going to give you a giant string of numbers that a curve wouldn't understand. Furthermore, your “c” variable isn't an instance of a hou.Parm so the calls to set/eval is going to error. Here are a couple of suggestions about the current code, not necessarily the logic.

The following line is totally overkill.
c = hou.Node.evalParm(hou.pwd(),“coord”)

hou.pwd() is giving you an instance of hou.Node so all that is necessary is to call hou.pwd().evalParm(). However, to fix the issue I mentioned about about set/eval of “c” not working, we could do something like this:
coord = hou.pwd().parm(“coord”)
c = coord.eval()
….
coord.set(coord.eval() + “ ” + pn)

This code is a proper way to do it. We get an instance of hou.Parm that we can use to set and evaluate. However, while this is correct, it runs into the problem of your joining creating a large amount of jibberish.

To convert the 3 instance of hou.Vector3 to a string for curve I'd do something like this:
coord_str = “”
for i in range(len(positions)):
coord_str += “%f,%f,%f ” % positions
The way joining works and the way you had it setup results in it separating each number in the string you give it by your “,”.

All the above doesn't actually really help the problem, but is more of the correct way to do it, even though the end result is incorrect. Attached is my take on it that uses a similar setup with the python operator.

In my scene I have my “road” sop which has a multiparm instance. This allows you to control the number of points you'd like to pick. The “Select Positions” button allows you to pick the positions whenever.

“Select Positions” does a callback into the Python Module's selectRoadPositions() function. This function runs the same selector code from your example, but assigns the number of points to pick based on the number we've set. Once the positions are selected, they get assigned to the parameters of the multiparm.

In the cook code of the operator, we generate a new polygon that will act as our curve and set it to not be closed so we will get a nice line. Then, for every position parameter, we generate a point at that position and create a vertex for our line using that point. I also have it generate a curve string like I mentioned above for the hell of it. The op is then finished and has generated a line. Rather than perform some type of calculation to create intermediate points, I just pipe the new curve into a Resample. Using “Resample by polygon edge” I can divide each line between the points into as many segments as I want. Much more efficient than trying to do any math. The less work the better!

Attachments:
road2.hip (59.7 KB)

Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
52 posts
Joined: June 2009
Offline
Hi Graham, Thanks a lot for the code, time and the explanation.
And regarding creating intermediate points, initially i thought of using a resample node but since it jus linear interpolates the points between the positions i switched to write math functions to get more noisy distribution of points.

Once again a thanks a lot..
  • Quick Links