Hello

Hello, this is the less formal but way more exciting part of my website where I post all of my tech experiments.

Search This Blog

Saturday, February 11, 2023

Running Bifrost Compounds through Houdini PDG

Running Bifrost compounds through Houdini PDG using bifcmd while passing in attributes dynamically is surprisingly simple

bifcmd is an executable that Bifrost provides to run Bifrost compounds headless through the command line.

STEP 1: build and publish a compound with no auto ports

For demo purpose I’ve made a simple Bifrost compound with a seed, index, and file_path input exposed this compound makes a cube randomly with a height between 1 and 2 and saves it to the file out location.


It looks like this inside
The cube looks like this
I will now publish the compound

Copy the namespace somewhere we will need that later as well as the path to the node save location

Mine Namespace is: User::Bifcmd::rand_cube_height

STEP 2: Set up environment in Houdini

Open Houdini

Create a top network

Dive inside

Select the local scheduler


Open the “Job Parms” panel

Scroll to the bottom and add an environment variable and name it PATH

We need to add the 3 folder paths to this Environment variable

the folder which contains bifcmd.exe (bifcmd.exe will launch a headless version of Bifrost):

C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost\bin

The Bifrost bifcmd dependency location:

C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost\thirdparty\bin

And the install location for BifrostUSD:

C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost\packs\usd_pack\0.21.11\thirdparty\usd-0.21.11\bin

The locations might be different on your computer

Join the locations with a semicolon:

C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost\packs\usd_pack\0.21.11\thirdparty\usd-0.21.11\bin;C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost\thirdparty\bin;C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost\bin

And paste them into the value box


STEP 3: add PDG attributes and shell command


Add a wedge node with count 10 and an integer attribute called seed



Set Seeds wedge type to value and the number to 0



Now place a generic generator node and connect it

In the generic generator check the run command in system shell button



Now we need to build the command

bifcmd C:\PATH_TO\rand_cube_height.json

this is the base command that tell bifcmd what json to use to run the node this should be the path to the published compound we made earlier

 

--set-port seed `@seed`

This flag will set given port to a given value. In this case the value is the PDG attribute @seed that we are passing in

 

--set-port index `@wedgeindex`

This flag will set given port to a given value. In this case the value is the PDG attribute @wedgeindex that we are passing in

 

 --set-port file_out C:\Proj\BifrostTools\BifCmd\output\cube`@wedgeindex`.usd 

This flag will set given port to a given value. In this case the value is the save path and we are using the PDG attribute @wedgeindex to make sure every iteration has a unique name. pick somewhere on your computer where you would like to save this

 

--bifrost-location "C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost"

This flag tells bifcmd where bifrost is installed

 

--compound-name "User::Bifcmd::rand_cube_height"

This flag tells bifcmd the namespace of the node we will run, this is important because the json we pointed to earlier could have multiple nodes in it

 

The final command should look something like this:

bifcmd C:\PATH_TO\rand_cube_height.json --set-port seed `@seed` --set-port index `@wedgeindex` --set-port file_out C:\Proj\BifrostTools\BifCmd\output\cube`@wedgeindex`.usd  --bifrost-location "C:\Program Files\Autodesk\Bifrost\Maya2023\2.6.0.0\bifrost" --compound-name "User::Bifcmd::rand_cube_height"

 

 Put your command in the generic generator

Select the generic generator and hit SHIFT- V

your output folder should now have 10 cubes

If you open each cube each one should be a different height


That’s it. You have now run a Bifrost node in Houdini


No comments:

Post a Comment