Jump to content

Infinite recursion in a script?


kursad

Recommended Posts

Hi

I am getting infinite recursion error(in the editor) in this simple Python code. I am putting this code in the X rotation of an object. Is it possible that the "origin" command causing this?

import math,hou
PI=3.14

v=hou.Vector4()

sphere=hou.node("/obj/sphere_object1")
box=hou.node("/obj/box_object1")

vs=sphere.origin().normalized()
vb=box.origin().normalized()

vd=vs[0]*vb[0]+vs[1]*vb[1]+vs[2]*vb[2]

degree= math.acos(vd)

return degree*180/PI

Link to comment
Share on other sites

What object are you putting this code in? If it is either the box or the sphere then you will get the recursion error since it is trying to set the transform while reading the transform at the same time.

As for your code, since you are just doing a dot product and converting to an angle between the vectors, you could replace the last 3 lines with a simple return vs.angleTo(vb) since it will perform the operations for you. You also wouldn't need to normalize.

Link to comment
Share on other sites

What object are you putting this code in? If it is either the box or the sphere then you will get the recursion error since it is trying to set the transform while reading the transform at the same time.

As for your code, since you are just doing a dot product and converting to an angle between the vectors, you could replace the last 3 lines with a simple return vs.angleTo(vb) since it will perform the operations for you. You also wouldn't need to normalize.

graham, I am putting in the X rotation of the box. I assumed that the rotation of the box might be independent of its transformation, although obviously it is a matrix operation. I am wondering what would be the right way to set this up then? Read the values in previous frames and set at the current frame maybe?

I can use Chops as well I was just trying to set this up with Python lines.

Ok thanks for the tip. I was not aware of those methods.

thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...