Jump to content
nicholas_yue

Python : hou creating/adding material style sheet ?

Recommended Posts

Hi,

  I am looking for way to create Material Stylesheet programmatically using Python.

  However, most of the search hit on stylesheet talks about UI stylesheet.

  Is there specific code example which illustrate how one could create and manipulate them ?

Cheers

Share this post


Link to post
Share on other sites

You can create stylesheets with hou.StyleSheet.__init__(json text). The json text is a string formatted as a json file, so I assume you can create presets, create a json file for each preset, and then load this json file and dump it in the init method.

More infos here : https://www.sidefx.com/docs/houdini/hom/hou/StyleSheet.html

 

 

Share this post


Link to post
Share on other sites

Am I correct to understand that Material Stylesheets operate at a global level and the association with the OBJ nodes are defined within the json text ? i.e. in a HIP file, there can be only one Material Style Sheet?

How does one retrieve a given Material Stylesheets (so that I can call asJSON() to study the format) ?

If there are multiple stylesheets, how does one assign them to Nodes ?

Cheers

Share this post


Link to post
Share on other sites

I think some of the question can be answer with the following screenshot. Material Style sheet are shop/mantra parameter on a per node basis.

Now I have to go find out how to programmatically create shop_materialstylesheet for a given node. Maybe something like this

odforce_material_stylesheet_shop.thumb.png.5cbaf4e74360910db3a295ffb8ab5ade.png

Share this post


Link to post
Share on other sites

you can have any number of stylesheets, both on scene level and object level. I tend to use scene level stylesheets however, as they're more versatile and I've experienced some odd behaviour when object level and scene level stylesheets are mixed together (may already have been fixed thou).

Stylesheets rely on json language and I think it's currently not possible to populate stylesheets using Python. However, with Python you can create an empty stylesheet and inject it with pre-existing json script, containing all the assignments and overrides. 

This json script can be either written from scratch, or generated from an existing stylesheet (that's a good way how to take existing material assignments and deploy it to different hip files).

cheers, D. 

Edited by davpe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×