writing a custom lookat constraint in a python node

   4102   4   0
User Avatar
Member
2 posts
Joined: June 2013
Offline
Im attempting to create a look-at node with a bit more control than the built in look-at constraint has. I have most of it figured out except for the actual look-at constraint part.

here's the code that's causing problems


if self_dist1 < max_dist:
lookatnode = lookat_obj
up_vec = hou.Vector3((0,1,0))

rotmat = self_node.buildLookatRotation(lookatnode, up_vec)

self_node.setCookTransform(rotmat)


and the python node I have it running in is spitting out the following error


Error: Python error: Traceback (most recent call last):
File “<stdin>”, line 41, in <module>
File “/op/hfs.current/houdini/python2.6libs/hou.py”, line 6917, in setCookTransform
return _hou.objNode_setCookTransform(*args)
OperationFailed: The attempted operation failed.
Python object is not cooking


any help would be much appreciated.

Thanks
Edited by - June 20, 2013 16:23:19
User Avatar
Member
702 posts
Joined: March 2009
Offline
Sorry if you've already checked this, but the only hint I have is from the doc page on the hou.ObjNode:

This method raises hou.OperationFailed if you call it on an object that is not implemented in Python or if you call it from outside that object’s Python cook code.

Does it help at all?

Cheers
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
User Avatar
Member
2 posts
Joined: June 2013
Offline
I've actually been pouring over the documentation on most everything mentioned in the error report, but thanks for the advice.
User Avatar
Member
8158 posts
Joined: July 2005
Offline
You can only call hou.ObjNode.setCookTransform() when you are inside the code for a Python Object.
User Avatar
Member
8158 posts
Joined: July 2005
Offline
PS. Instead, extract out the translates, rotates, scales and set those values into the corresponding object parameters instead.
  • Quick Links