Jump to content

Make Python Run Every Frame For MDD Export?


Atom

Recommended Posts

Hi All,

I have several python scripts inside of a FBX Import subnet. The scripts needs to run in a certain order. One script controls the bones via sliders. Another script sets values on those sliders in the other script to produce an auto walking character. This works fine when I click playback on the timeline.

However, when I try to export a MDD file of this animation I only get a static result. Also the export goes by very fast and the progress bar never pops up.

My conclusion is that the python scripts are not running every frame thus the exporter sees the same object on every frame.

I did try setting the frame directly in the Pre-Render script by setting the script type to python and using the following code.

hou.setFrame(hou.frame())

Is there any way to make my python script run every time the frame changes?

Link to comment
Share on other sites

How do I do that?

What is the syntax for calling the external Python node from the MDD Pre-Frame single line text field?

My Python node has over 100 lines of code and references 30-40 custom parameters on itself. To migrate all those custom parameters into the MDD node would take a while and there is still no guarantee that would work. As I mentioned above the Pre-Render field seems to have no effect when I place code in it.

 

Link to comment
Share on other sites

Thanks, I do have a work around at this time. I put a File Cache node in write mode and export an OBJ file. Then I press Play on the timeline and it does kick out a mesh for every frame because the Python scripts run when the timeline changes. After that I bring that mesh sequence into it's own geo via the File node. This scrubs just fine and I point the MDD exporter to this temporary geo playback node. I can then kick out a MDD file from that temporary file. Kind of a long winded way to achieve the goal but it does work.

Edited by Atom
  • Like 1
Link to comment
Share on other sites

I did find a better way to solve this problem.

Simply force cook your python node in the Pre-Frame or Post-Frame Script fields.

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

You can force cook multiple python nodes as well. The order that you force the cook is the order that the nodes will run in.

Edited by Atom
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...