nicholas_yue Posted September 20, 2020 Share Posted September 20, 2020 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 Quote Link to comment Share on other sites More sharing options...
DonRomano Posted September 20, 2020 Share Posted September 20, 2020 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 Quote Link to comment Share on other sites More sharing options...
nicholas_yue Posted September 20, 2020 Author Share Posted September 20, 2020 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 Quote Link to comment Share on other sites More sharing options...
nicholas_yue Posted September 20, 2020 Author Share Posted September 20, 2020 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 Quote Link to comment Share on other sites More sharing options...
davpe Posted September 22, 2020 Share Posted September 22, 2020 (edited) 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 September 22, 2020 by davpe Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.