Jump to content

Force Recooking Python Sop over time


Recommended Posts

Hi all,

I'm working on a python sop, to move points along the time, and i've got a problem : the sop is not cooked at every frame, how can i change that ? how can i force it to recook at each frame ???

I've searched on this forums and found old solutions which d'ont works within houdini 9.5 ( for example flags.setTimeDep() etc....)

Thanks a lot.

Link to comment
Share on other sites

Hi all,

I'm working on a python sop, to move points along the time, and i've got a problem : the sop is not cooked at every frame, how can i change that ? how can i force it to recook at each frame ???

I've searched on this forums and found old solutions which d'ont works within houdini 9.5 ( for example flags.setTimeDep() etc....)

Thanks a lot.

hi, can't check right now, but maybe this trick will be useful - put somewhere 0*$T. or in python terms, 0*hou.frame() ..

Edited by mic
Link to comment
Share on other sites

I think that's the good function, but I'm trying it but i'm not able to use it correctly.... Argh!

The doc says cook(self, force=False, frameRange=())

So i use it like this, but this returns an error... I don't understand why...

start = 1

end = 200

force = True

frameRange = (start, end)

hou.pwd().cook(force, frameRange)

//edit : this works with the python shell ( hou.node("obj/geo1/myNode1/").cook(True, frameRange) ), not inside the python sop

Edited by Div
Link to comment
Share on other sites

Getting python sops to be time dependent can be tricky. The easiest way to force time dependency is to just do something like:

frame = hou.frame()

Causing the cook function to evaluate the frame number will always cause the node to become time dependent.

Depending on what it is I'm doing I'll sometimes have a toggle on my SOP that will toggle it on/off depending on how my sop is designed or what I would like it to be doing:

if pwd().parm("force_timedep"):
	frame = hou.frame()

Edited by graham
Link to comment
Share on other sites

I agree with your method but it doesn't works. I explain : my python sop read the position of the point, and add to it a processed value. But the python sop doesn't seems to read the point position for each frame, only for the first one, even if i put somewhere in my code hou.frame(), even if i add to the position a random value with hou.frame() as a seed...

Example Of what i'm trying to achieve:

#assume that pt is the point.

ptPosX = pt.position()[0]
ptPosX = ptPosX + vX
newPos = (ptPosX, ptPosY, ptPosZ)
pt.setPosition(newPos)

Edited by Div
Link to comment
Share on other sites

This is to be expected since it's essentially wanting to be recursive and use it's gdp value from the previous frame which no SOPs really allow. The only way to do that is to get some sort of SOP Solver simulation involved, or maybe write out to disk files with all the positions after each cook. You could probably try and do something with the Feedback proto install SOP. It's specially designed to do this type of thing.

Link to comment
Share on other sites

Hmm, there seems to be no documentation whatsoever for proto install or the operators. Oh well.

Proto install operators are operators that come with Houdini but are not in the main build because they aren't supported/tested (I think?). You can manually install them by running the "proto_install" command from a shell that has the Houdini environment initialized.

This loads up the proto install app and you can choose to install certain operators and where to install them. In this case you could install SOP_Feedback and give it a test.

  • Like 1
Link to comment
Share on other sites

  • 5 years later...

As was mention above, putting simple hou.frame() will work. Don't know why you have problems with that. For example:

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
for point in geo.points():
    pos = point.position()
    pos += hou.Vector3(0, hou.frame(), 0)
    point.setPosition(pos)

Will make sop time dependent. MMB click on sop and see it at the bottom. If you need geometry from previous cook, then sop solver would be easy and faster, but you can also get geometry from any frame in python. This method was introduced some time ago...

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...