# AppSDK: Export Material

**URL:** <https://forums.chaos.com/t/appsdk-export-material/100037>\
**Category:** General\
**Created:** [August 17, 2020, 11:36am UTC](https://forums.chaos.com/t/appsdk-export-material/100037 "2020-08-17T11:36:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbvfx](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jbvfx](https://forums.chaos.com/u/jbvfx)\
**Post date:** [August 17, 2020, 11:36am UTC](https://forums.chaos.com/t/appsdk-export-material/100037/1 "2020-08-17T11:36:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bdancer](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/bdancer/32/52257_2.png) [@bdancer](https://forums.chaos.com/u/bdancer)\
**Post date:** [August 17, 2020, 11:41am UTC](https://forums.chaos.com/t/appsdk-export-material/100037/2 "2020-08-17T11:41:43Z")

</div>

AppSDK could export anything.  
[https://docs.chaosgroup.com/vray\_app…on27/vray.html](https://docs.chaosgroup.com/vray_app_sdk/doc/python27/vray.html)  
There is an export() method which accepts “pluginExportList” argument to export only particular plugins.

---

<div class="post-metadata">

**Author:** ![jbvfx](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jbvfx](https://forums.chaos.com/u/jbvfx)\
**Post date:** [August 17, 2020, 1:31pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/3 "2020-08-17T13:31:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bdancer](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/bdancer/32/52257_2.png) [@bdancer](https://forums.chaos.com/u/bdancer)\
**Post date:** [August 17, 2020, 1:36pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/4 "2020-08-17T13:36:48Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![bdancer](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/bdancer/32/52257_2.png) [@bdancer](https://forums.chaos.com/u/bdancer)\
**Post date:** [August 17, 2020, 2:10pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/5 "2020-08-17T14:10:52Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![bdancer](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/bdancer/32/52257_2.png) [@bdancer](https://forums.chaos.com/u/bdancer)\
**Post date:** [August 17, 2020, 2:19pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/6 "2020-08-17T14:19:02Z")

</div>

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

```auto

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:

```auto

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

```

---

<div class="post-metadata">

**Author:** ![jbvfx](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jbvfx](https://forums.chaos.com/u/jbvfx)\
**Post date:** [August 19, 2020, 4:06pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/7 "2020-08-19T16:06:42Z")

</div>

Great. Thanks.

That’s exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![jbvfx](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jbvfx](https://forums.chaos.com/u/jbvfx)\
**Post date:** [August 21, 2020, 10:03am UTC](https://forums.chaos.com/t/appsdk-export-material/100037/8 "2020-08-21T10:03:13Z")

</div>

A quick followup question.

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

---

<div class="post-metadata">

**Author:** ![jbvfx](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jbvfx](https://forums.chaos.com/u/jbvfx)\
**Post date:** [August 28, 2020, 12:40pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/9 "2020-08-28T12:40:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bdancer](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/bdancer/32/52257_2.png) [@bdancer](https://forums.chaos.com/u/bdancer)\
**Post date:** [August 28, 2020, 12:56pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/10 "2020-08-28T12:56:29Z")

</div>

\> 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](https://docs.chaosgroup.com/vray_app_sdk/doc/python27/index.html) then probably no…

---

<div class="post-metadata">

**Author:** ![stanislav.kirilov](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/stanislav.kirilov/32/52485_2.png) [@stanislav.kirilov](https://forums.chaos.com/u/stanislav.kirilov)\
**Post date:** [August 28, 2020, 2:15pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/11 "2020-08-28T14:15:05Z")

</div>

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:

```auto

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

---

<div class="post-metadata">

**Author:** ![jbvfx](https://avatars.discourse-cdn.com/v4/letter/j/f05b48/32.png) [@jbvfx](https://forums.chaos.com/u/jbvfx)\
**Post date:** [August 29, 2020, 12:29pm UTC](https://forums.chaos.com/t/appsdk-export-material/100037/12 "2020-08-29T12:29:47Z")

</div>

Great, thanks Stan.
