kursad Posted July 6, 2011 Share Posted July 6, 2011 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 Quote Link to comment Share on other sites More sharing options...
graham Posted July 6, 2011 Share Posted July 6, 2011 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. Quote Link to comment Share on other sites More sharing options...
kursad Posted July 6, 2011 Author Share Posted July 6, 2011 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 Quote Link to comment Share on other sites More sharing options...
edward Posted July 7, 2011 Share Posted July 7, 2011 I think the easiest way by far is to add a child object of box and put your expression on the child instead. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.