art3mis Posted July 22, 2017 Share Posted July 22, 2017 In my attempt at solving a pull focus issue I sourced the following script here on odforce. I then paste into a Python Script digital asset node. But how to get it to run/compile? Should it run automatically? #!/usr/bin/env hython _version = 0.11 ''' Inital Author: "SYmek" from od[force] community. Edited by: Farsheed Ashouri Thanks to everyone who have helped. For more information: http://forums.odforce.net/index.php?/topic/9725-creating-a-new-python-script-for-automating-camera-dof-setup-solved/ ''' import hou def computeFocus(): if hou.selectedNodes(): for node in hou.selectedNodes(): # print node.path() if node.type().name() == "cam": camera = node # else: target = node target = hou.node("/obj").createNode("null","DOF_Controler") theExp='vlength(vtorigin("%s", "%s"))' try: camera.parm("focus").setExpression(theExp % (camera.path(),target.path())) # cT = camera.worldTransform().extractTranslates() # tT = target.worldTransform().extractTranslates() # try: camera.parm("focus").set(cT.distanceTo(tT)) print "Done." except: print "Did you actually select any camera?" else: print "Please select a camera and a target." #if __name__ == "__main__": computeFocus() 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.