hyview
is a library for interacting with Houdini remotely. It provides a simple API for executing remote calls and ships with functionality for sending geometry points.
The apprentice version is available for free and comes with limited restrictions:
Houdini Apprentice is a free version of Houdini FX which can be used by students, artists and hobbyists to create personal non-commercial projects.
https://www.sidefx.com/products/houdini-apprentice/
git clone https://github.com/sambvfx/hyview.git
cd hyview
Make virtualenv for Houdini. This will create a venv
folder inside the cloned directory.
bin/buildenv
Create your own virtualenv. Use Python 3 if you want!
virtualenv -p python3 venv3
Start Houdini from the launcher. You may have to update the launcher to point at your Houdini install location.
TIP: You can set the environment variable
HOUDINI_CMD
to override the default the path to the houdini executable.
bin/launch_houdini
TIP: Within Houdini, change to the
Technical
desktop to load a layout better suited to our needs.
In the Python Shell
within Houdini type:
import hyview
hyview.start_houdini()
This will start the server in Houdini we can interact with.
Start up another python process (which can be python 2/3) and send some test data to it to ensure it works:
import hyview_samples.rand
hyview_samples.rand.sample()
hyview
is built around a few simple concepts.
- Simple interface
- Data exchange utilizes abstract representations of Houdini data types.
hyview.Geometry
andhyview.Point
- Bulid geometry in Houdini by simply passing a
hyview.Geometry
object tohyview.build
- Support for passing custom Houdini attributes. See
hyview.AttributeDefinition
.
- Data exchange utilizes abstract representations of Houdini data types.
- Aggressive and safe caching
- By default results are cached to disk immediately for performace. Providing the same data twice will use the disk cache if one exists.
- Easy to extend with custom RPC methods.
- Provides an easy way to execute remote commands in Houdini.
You can provide your own RPC methods to call. For example:
# mymodule.py
import hyview
@hyview.rpc()
def mesh_all():
"""
Create a particle fliud mesh for all geo within the hyview root subnet.
"""
import hyview.hy.core
for node in hyview.hy.core.root().children():
last = node.children()[-1]
if 'particlefluidsurface' in last.type().name():
# already meshed
continue
p = node.createNode('particlefluidsurface')
p.parm('particlesep').set(8)
p.parm('transferattribs').set('Cd')
p.setInput(0, last)
p.setDisplayFlag(True)
To ensure this RPC method is available in Houdini we need to make sure it's picked up by the server we start. There are a few ways to accomplish this:
When starting the server, optional path(s) can be provided which will be added to the RPC registry.
import hyview
hyview.start_houdini('/path/to/mymodule.py')
Or set them as environment variables before you launch.
export HYVIEW_PLUGIN_PATH=/path/to/mymodule.py:/path/to/manypluginsdir
You can then call this procedure like you would normally (from another python session) - which will issue the RPC command to execute it remotely.
import mymodule
mymodule.mesh_all()
Note you'll need to scope all Houdini specific imports.
This repo contains a handful of samples to get you jump started. These are simple proof of concepts to illustrate how to use hyview
.
NOTE: Some of these samples require files to be downloaded and/or additional python packages to be installed.
This is electron microscopy data and comes with a corresponding array of labels. Filtering to only specific labels provides some interesting results.
Download sample data from https://cremi.org/static/data/sample_A_20160501.hdf
Place the sample file in ./hyview_samples/_data
NOTE: You'll have to
pip install h5py
to load the data.
Use the helper to view something interesting!
import hyview_samples.neuron
hyview_samples.neuron.sample()
This is fluorescence microscopy data over multiple time points. It's a 5D array with two channels (DNA and microtubules).
Download sample data from https://www.dropbox.com/s/dnq0ag1xbc6ft2u/mitosis.tif?dl=0
Place the sample file in ./hyview_samples/_data
NOTE: You'll have to
pip install scikit-image
to load the data.
Use the helper to view something interesting!
import hyview_samples.mitosis
hyview_samples.mitosis.sample()