Jump to content

Labs Maps Baker - auto fbx export??


papsphilip

Recommended Posts

Diving inside the network i can see the rop fbx responsible for exporting the low res fbx geo.

I am trying to do the same thing in an other setup but i cant figure out how does it get triggered.

Usually you have to press the Save button or build a TOP network. i dont see any TOP networks inside the HDA

Capture.JPG

Link to comment
Share on other sites

  • 1 month later...

This is triggered using a Python script on the HDA itself.

Here's the short version :
To see the script, right click the HDA → Type Properties
image.png.a32676d31fc1ffd98a080239b930e28b.png
Go into the Scripts tab. There's some stuff in there, but we are looking for one keyword in particular, the name of the ROP FBX Output node. Lo and behold, line 20, there it is → a_node.node("low_export").render()
image.thumb.png.588d9cb65fd97ccb09ccd94e095365ff.png

 


That's all nice and well, but how did I get there (aka Reverse Engineering 101). I realize that some of the investigation steps may not be obvious to a beginner in Houdini, as there are a few hoops to jump through.
So here's some more explanation.

It is strongly recommended to note the name of the ROP FBX Output node and keep it in mind during our investigation.
Dive inside the HDA and take a note of FBX node name. "low_export". Gotcha.

image.png.3ab282ac3be8154775b3463fb289c5af.png

So then, let's first start with the end. What triggers the fbx to export in the first place ? Why, it's the Render button on the HDA ! Let's start with this fella.
image.png.101ee911289893656eec8c5db0ffc5c1.png

Let's open Type Properties and see what happens when we press that Render button.
Ah, there's a callback script on the button → kwargs['node'].hm().Render(kwargs['node'])
image.thumb.png.b93e5c8b95bbc35b8250905cb45fab77.png

What's all this then ?
A callback script is a (generally) small script that executes when the button is pressed. You could print("Hello World") in it, set some parameter value, etc etc. Note that the icon on the right is the Python logo, which was manually changed from the default Hscript, meaning that this expects a Python script.
kwargs is a dictionary containing some info about the node and parm it's called from. https://www.sidefx.com/docs/houdini/hom/locations.html#call (ctrl+f search for kwargs in the page)
Breaking this down, kwargs['node'] means the current node (the HDA itself), hm() is the asset's Python module (that info is in the same page ↑ if you search "hm()"), and Render(kwargs['node']) is a custom function, taking the current node as a parameter.
In not-so-layman's terms, the button calls a function from the Python Module on the HDA.
So, let's go the the Scripts tab on the HDA, and take a look at the Render() function. (Look at the second picture, I won't copy it here again for the sake of not making this message any bigger than it is)

Alright, it's doing a few stuff about frame mode and ranges, we don't care about that, something about cook (cook miiight sound interesting but it's for the foreach_end1, so let's skip that), and then aha ! "low_export" ! Interesting
So, it's calling .render() on the low_export node. That sounds like the answer ! (because it is)

One more nice step is to figure out where does this render() function comes from. What if we want more info about it, pass some arguments ?
We can print stuff out to figure out stuff. We can take a look at the type() of a node with print(type(nodeName))
If we print(type(a_node.node("low_export"))), we'll see <class 'hou.RopNode'>. This will allows us to take a look at the documentation for the node (not for the FBX Output node specifically, but for the overarching node type, the "parent" from which the FBX Output inherits stuff from)
https://www.sidefx.com/docs/houdini/hom/hou/RopNode.html
And, right there, render(aBunchOfOptionalArguments)
Taking a look at the description, we won't be surprised with it.
That wasn't a necessary step in this context, but it is super useful to know how to find stuff out in the documentation. What can we do with a node, what is this or that argument, etc etc.

 

Note that there is another solution for exporting the fbx, and that's the pressButton() function.

https://www.sidefx.com/docs/houdini/hom/hou/Parm.html (search for pressButton).
Those are equivalent.

a_node.node("low_export").render()
a_node.node("low_export").parm("execute").pressButton()

 

Link to comment
Share on other sites

Hi Alain.

I've followed your steps, and after setting the python code in Scripts Tab:
 

def Render(a_node):
    a_node.node("FBXExportNode").render()
    a_node.node("FBXExportNode").parm("execute").pressButton()

and having the Callback Script line using :
 

kwargs['node'].hm().Render(kwargs['node'])

I can render the FBX output.

But what i don't understand is how we can trigger this once the HDA is cooked via an HDA Processor then.

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