[python scripting] adding shader attributes in python

59 views
Skip to first unread message

Jérémy Ringard

unread,
Feb 3, 2021, 3:26:16 AM2/3/21
to Golaem List
Hi,

I'm trying to add custom shader attributes on all my char meshes but it doesn't seem to work
My sourcepath is a gcha file with skeleton and meshes.
before adding any attribute, I'm already stuck at the point of adding a shadingGroup node on the meshes.
I guess I'm not using the function correctly. To be honnest I find the syntax a bit confusing :)

#retrieve the list of geometry nodes 
nodelist = cmds.glmCharacterMaker(script=True, 
                        file=sourcepath, 
                        listGeoNodes = True)

#adding shading group on each
for node in nodelist:
    if 'gmsh' in node:
        addednode = cmds.glmCharacterMaker(script=True, 
                        file=sourcepath, 
                        addGeoNode=["ShadingGroupNode", "testnode"], 
                        outputFile=saveAs)
        cmds.glmCharacterMaker(script=True, 
                        file=saveAs, 
                        editProperties=["ShadingGroupNode", addednode, 'parent='+node], 
                        outputFile=saveAs)
 
when I open the "saveAs" file, I can't see any change
Am I missing something ?

(I'm using V7.3.5 on maya 19 linux)

thanks !

Nicolas Chaverou

unread,
Feb 3, 2021, 5:11:08 AM2/3/21
to Golaem List
Hey Jeremy,

When creating a new node in a Character File, it is discarded when the file is saved if it is not connected to the main graph.
Thus you need to merge your two commands in one.

Here's an example below:

import maya.cmds as cmds
inCharFile = 'D:/testChar.gcha'
outCharFile = 'D:/testCharOut.gcha'

cmds.glmCharacterMaker(script=True, file=inCharFile,
                        addGeoNode=['ShaderAttributeNode', 'myAttrNode'],
                        editProperties=['ShaderAttributeNode', 'myAttrNode', 'parent=myShadingGroup'],
                        outputFile=outCharFile);

And the before / after in the Character File

2021-02-03 11_05_03-Golaem Character Maker.png
2021-02-03 11_05_52-Golaem Character Maker.png

Hope that helps
Best,


--
Note that crowd...@golaem.com is a public list.
If for any reason (confidential project, sending production files...) you need to post a private message to Golaem Support, please use http://support.golaem.com
---
You received this message because you are subscribed to the Google Groups "Golaem List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crowd-list+...@golaem.com.
To view this discussion on the web visit https://groups.google.com/a/golaem.com/d/msgid/crowd-list/157d17fc-966d-490f-b26b-dea8a910c540o%40golaem.com.

Jérémy Ringard

unread,
Feb 4, 2021, 1:41:03 AM2/4/21
to Golaem List
it works like a charm, thank you Nico !

one last thing: I'm trying to add a string attribute on each mesh. Aparently the attribute name is related to the name of the ShaderAttr node. Does that mean I can't have the same attribute with a different value for each geometry?


Le mercredi 3 février 2021 05:11:08 UTC-5, nicolas.chaverou a écrit :
Hey Jeremy,

When creating a new node in a Character File, it is discarded when the file is saved if it is not connected to the main graph.
Thus you need to merge your two commands in one.

Here's an example below:

import maya.cmds as cmds
inCharFile = 'D:/testChar.gcha'
outCharFile = 'D:/testCharOut.gcha'

cmds.glmCharacterMaker(script=True, file=inCharFile,
                        addGeoNode=['ShaderAttributeNode', 'myAttrNode'],
                        editProperties=['ShaderAttributeNode', 'myAttrNode', 'parent=myShadingGroup'],
                        outputFile=outCharFile);

And the before / after in the Character File

2021-02-03 11_05_03-Golaem Character Maker.png
2021-02-03 11_05_52-Golaem Character Maker.png

Hope that helps
Best,


To unsubscribe from this group and stop receiving emails from it, send an email to crowd...@golaem.com.

Nicolas Chaverou

unread,
Feb 4, 2021, 4:22:55 AM2/4/21
to Golaem List
Hey there,

See inlined below:

On Thu, Feb 4, 2021 at 7:41 AM Jérémy Ringard <jeremy....@gmail.com> wrote:
it works like a charm, thank you Nico !

one last thing: I'm trying to add a string attribute on each mesh. Aparently the attribute name is related to the name of the ShaderAttr node. Does that mean I can't have the same attribute with a different value for each geometry?

Yes that's correct : Shading Attribute Node have unique names in the Character File
Are you string to add the same Shading Attribute to all meshes but with different values? or with the same value?
Can you describe what's the use case?

Best,
 
Reply all
Reply to author
Forward
0 new messages