Jump to content

Embed .h files in Digital Assets for use with wrangle nodes


Kino

Recommended Posts

I have a subnet which I intend to transform to a .hda asset. Inside the subnet there are wrangle nodes and some of them include a couple of .h header files from houdini/vex/include folder. Now my question is how can I attatch/embed these header files in the asset so I don't need to copy files separately?

1- Can an asset embed header files and then copy them to a certain folder when a user is installing them?
2- Or maybe I can somehow embed the header files in the asset and then include them in the wrangle nodes with a relative path?

Thanks in advance for any suggestions

Link to comment
Share on other sites

Not sure about such embedding, but there is "Outer Code" field on Snippet VOP. Try to unlock the Wrangle node and paste code in that field, and then remove include lines. Or link it to a spare parameter on the Wrangle's interface, it will make it more clear, why the node was unlocked. If "houdini/vex/include" is some default Houdini library, there is no need to embed it.

outer_code.hipnc

Link to comment
Share on other sites

Thanks for the tip.

I knew about the "Outer Code" field but copying code there makes code management and revision really hard. Think 10 wrangles nodes and to update them globally I can either change the code in the included header OR copy and paste the new code in 10 nodes which will be not easy if you want to do it repeatedly. If there's no other way I guess I'd have to develop with the custom header in the include path and then for exporting the digital asset copy the final code in the "Outer Code" field, still I wish there was a better way because this still makes it hard for the users of the hda to see the code and fiddle with it in the future.

Link to comment
Share on other sites

As an idea, you also can read text from HDA section into parameter, and then expand it using HScript. No need to use outer code and unlock anything, included library will be expanded into snippet's function body. It works on example, but not sure if applicable at all. It is a weird way to deal with libraries outside some special cases, however. Any editing will require asset definition update, and editing from sections is not very convenient either.

 

It is generally better to use proper dependencies from search directory. And since most of the snippets usually require a couple of functions which don't need to be maintained, simple copying usually works. Some Houdini tools also go with such chunks of VEX inside snippets.

embedding_test.zip

Edited by f1480187
Link to comment
Share on other sites

Thanks mate,

that actually is a really neat idea. I like it more than the outer code method because the code to main only stays in one place/ param and also the hda is easily distributable without any external dependancies. Is the Hscript expand done by the backticks (what do the backticks do in VEX)?

Link to comment
Share on other sites

On second thoughts, this will not work because the header file I want to include contains struct definitions and function defs that return arrays, both of which are not doable if stated in the beginning of the wrangle nodes (since they are function definitions themselves). So back to square one I guess.
Also I found this thread which wants something similar but with python modules. According to this, one other solution is to embed the .h files in the external files tab of the asset and then copy it to the $VEX folder via a python instruction (not even sure this is possible) : https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=43325. Still I think I'd prefer the first method you mentioned (the way with outer code fields)

EDIT : On third thoughts, I think I can mix your idea with the tex param and the outer code method. Think `chs("myLib")` in the outer code fields. Damn Houdini for never disappointing the user :)

Edited by Kino
Link to comment
Share on other sites

Totally forgot about array functions are not possible inside body of other functions (which is what the snippet is, according to generated VEX code). Glad to hear you finally find the solution. Python modules embedding is straightforward, there is native functionality allowing to do it, including HOM's special function mentioned in link. Actually, there are some tools coming with pypi packages as sections which I currently use. So, it is different case.

 

Is the Hscript expand done by the backticks (what do the backticks do in VEX)?

You are right. Code field is a normal string parameter. HScript Expression evaluates there as usual. MMB on parameter's label to see it in evaluated form:

 

cTY5SGB.gif

 

That's how Import * Attribute VOPs implemented with such expression hacks. So, backticks never occur in VEX. Try RMB / VEX/VOP Options / View VEX Code... on Attribute VOP node inside Wrangle to see final VEX code.

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

Amazing tip, that's a very powerful feature. Since you mentioned this I actually used it in another part of the asset as well. There was a wrangle that needed some initialization in the beginning and some closure code at the end, to hide these from the user's point of view I added a code field on the interface of the asset and for the mentioned wrangle I wrote:

 

//Init code
.
.
.


//Users code
`chs("../mUserCodeField")`

//Closure code
.
.
.

Thanks again f1480187! You were a great help, I'll soon share the asset in the forums and will also mention it here so you can have a teacher's look at it :)

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

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