Jump to content
leytonian

Forcing file load via Python

Recommended Posts

Hi

 

I create a small python script in the filename entry to load my files. The python code returns the correct file name and path in the filename box. It is all good. But the problem is that I cant get it to load files automatically as the frame advances. I ahve to manually press "reload sequence" on every frame. Please bear in mind that the file names are generated at each frame by reading file names in certain folders so there is no pregenerated file scheme.

 

I tried hou.iu.triggerUpdate but that did not do anything. I also tried the to eval the Reload sequence parm which is reload. That did not work either.

 

 

I am hoping that someone here might have a better suggestion to get the reload going. Because as of now I cant render. Render out or Rop out does not work because it is not loading the files ;(

Share this post


Link to post
Share on other sites

You can place a force cook in the Pre-Frame Script field of the Render ROP, MDD or File Cache. Make sure to change the expression language to from hScript to Python.

Adjust the path to your node.

hou.node('/obj/my_python_node').cook(force=True)

This won't help your frame change but it will cause your script to run every frame during the render.

Edited by Atom

Share this post


Link to post
Share on other sites

You can also use node.parm("reload").pressButton() function :)

 

Heres a shelf tool I made for myself one day to reload anything in my scene pointing to outside files:

 

import hou, toolutils, os, sys

def getNodes(type):
    return toolutils.findAllChildNodesOfType(hou.node("/"),type,dorecurse=True)
       
def reloadFiles():
    for node in getNodes("file"): ## Replace file with whatever operator type you want
        print ("Reloading: " + node.name() + " @ " + node.path() )
        try:
            node.parm("reload").pressButton() ## replace reload with whatever the name of the button is
            print "Success!"
        except:
            print ("Failed To Reload: " + node.name() + " @ " + node.path())
            continue
reloadFiles()

 

It may be a little overkill but I found it to work pretty well :)

 

-Nathan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×