Jump to content

Forcing file load via Python


leytonian

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 ;(

Link to comment
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
Link to comment
Share on other sites

  • 4 weeks later...

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

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