AppSDK: Export Material

Is it possible in the App SDK to export a material from a Houdini path similar to vray.utils.exportMaterial(“”) in VRay for Maya’s Post Translate?

AppSDK could export anything.
https://docs.chaosgroup.com/vray_app…on27/vray.html
There is an export() method which accepts “pluginExportList” argument to export only particular plugins.

But how would I export a material that isn’t assigned to anything in Houdini for later doing the assignments in the App SDK?

In Maya I would:
import vray.utils as vr
mat = vr.exportMaterial(‘myMaterial’) ## export material from Maya to VRay, that isnt assigned to anything in the scene
node.set(‘material’, mat) ## assign that material to a Node in the VRay scene

Ah, so you don’t need to export it to the vrscene file?

> But how would I export a material that isn’t assigned to anything in Houdini

There is Object → Force Materials list.
Then you can get plugin by name, it’s usually just the node path with / converted to | (like /mat/vrayMtl1 → |mat|vrayMtl1).

We could add such API at some point…

But unfortunately this:
node.set('material', mat) ## assign that material to a Node in the VRay scene
wont work in Houdini…
We heavily use Instancer2 plugin and material is set via Instancer2 “instances” list item…

I’ve added exportMaterial() API to the next nightly build…
The only difference will be material assignment (regarding the info the in previous post):


import vray

r = vray.VRayRenderer()

matPluginName = self.exportMaterial("/mat/vrayMaterialBuilder")

objNode = r.plugins["|obj|box1|node"]
objNode.geometry.instances_material_override = r.plugins[matPluginName]

“self” syntax may be a bit misleading, but in this context it’ll mean current ROP so that:
self.exportMaterial("/path/to/mat") will be internally replaced with:


_vfh_ipr.exportMaterial(rop="/path/to/this/rop", mat="/path/to/mat")

Great. Thanks.

That’s exactly what I was looking for.

A quick followup question.

How do you duplicate a Plugin node in the App SDK? Similar to node.duplicate(name) in Post Translate (Maya)

@bdancer: Did you get chance to look at this?
Is it possible to duplicate a Plugin, creating a new instance with the same properties?

> How do you duplicate a Plugin node in the App SDK?

If there is no such method here https://docs.chaosgroup.com/vray_app…n27/index.html then probably no…

Hi jbvfx,

We have plans to add utility functions to copy/clone/duplicate plugin instances from one renderer instance to another but that would work in the same renderer too. But we haven’t done it so far. So currently the solution would be to write a helper method yourself. it’s pretty straightforward if you don’t use animated/interpolated params but it’s not very hard even if you do. Here is a sample function which duplicates a plugin in the simples case when there are no animated params:


def duplicatePlugin(plugin, newPluginName):
  newPlugin = plugin.getClass()(newPluginName)
  for propName in newPlugin:
    if plugin.getMeta(propName)['runtimeType'] != 'Unspecified': # skip unset properties
      propValue = plugin[propName]
      if propValue != plugin.getReference(propName): # alternative plugin outputs are read as referencing themselves; skip them
        newPlugin[propName] = propValue
return newPlugin

You can add exception handling if needed.

Best regards,
Stan and the AppSDK team

Great, thanks Stan.