joefit Posted March 9, 2016 Share Posted March 9, 2016 Hi! I'm new in Houdini and I have a problem. I created and SOP object where the animation of it is controlled through DOP object and an script of python. I trying to to record the different positions of the object through the simulation. But, always my script returning the Initial position value when the simulation runs. This is a piece of my python script: #Houdini Library import import hou #Function that allow us to set the number of playbar's frame. def playbarFrame(frame): try: hou.setFrame(frame) except Exception as e: print type (e) #Function that allow us to start the simulation once. def startSimulation(): try: hou.playbar.setPlayMode(hou.playMode.Once) hou.playbar.play() except Exception as e: print type (e) #Function that allow us to stop the simulation. def stopSimulation(): try: hou.playbar.stop() except Exception as e: print type (e) #Function that allow us know the current frame. def currentFrame(): try: return hou.frame() except Exception as e: print type (e) #Function that allow us kwow if the simulation is working. def isWorking(): try: return hou.playbar.isPlaying() except Exception as e: print type (e) #Function that return us the value of the sphere's y-axis. def sphereMove(): try: #Loading a geometry and parameters geo = hou.node('/obj/sphere_object1/transform1') #Initial value of the geometry in 'y'-axis geoPos=geo.geometryAtFrame(hou.frame()).boundingBox().center()[1] return geoPos except Exception as e: print type (e) #************************************************************************ # Main function of the script # Description: Main function that calling functions for the control # of sphere. #************************************************************************ def main(): try: #If the simulation is stopped we run it. if isWorking()==False: #Initializing the crack var and the umbral var crack= True umbral= 0.5 #Setting the playbar at first frame before the simulation start. if currentFrame()>1.0: playbarFrame(1.0) #Running the simulation at first time. startSimulation() #Calling an event when the animation has started through an iteraion while isWorking()and crack== True: pos = sphereMove()#searching value position print pos else: stopSimulation() except Exception as e: print type (e) What can I do? Where is the problem? how could I take the value from the dop node? Thanks Quote Link to comment Share on other sites More sharing options...
Atom Posted March 9, 2016 Share Posted March 9, 2016 (edited) Hmm...Wrapping all those big sections of code in try/except is just asking for ambiguous operation. Remove all your try excepts so you can see where the error is occurring. I would guess the way you are fetching the position is not really working as expected. Is your simulation truly changing the transform1 node of the master object transformation? geo = hou.node('/obj/sphere_object1/transform1') Have you tried fetching the transformation parameters directly? geo = hou.node('/obj/sphere_object1') x = geo.parm("tx").eval() y = geo.parm("ty").eval() z = geo.parm("tz").eval() It is hard to say without seeing the HIP file. Is the python node inside a network that it is trying to drive? It might be better to not "force" the simulation playback from python. Instead write your python to simply evaluate the current frame that it finds itself executing on. Then the standard timeline playback can be used to control the result. Edited March 9, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
joefit Posted March 10, 2016 Author Share Posted March 10, 2016 Hi Atom, I erased all the 'try' and I wrote the code following your example. I have had the same result. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
joefit Posted March 10, 2016 Author Share Posted March 10, 2016 Hi, I found it through the expession of the line below. >>> hou.node('/obj/sphere_object1/dopimport1').geometry().pointFloatAttribValues('P') Thanks for your contribution See you soon 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.