Community
Arnold for 3ds Max
Rendering with Arnold in 3ds Max using the MaxtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why does this code not create Utility Shaders i can see in the Hypershade?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Christoph_Schaedl
342 Views, 7 Replies

Why does this code not create Utility Shaders i can see in the Hypershade?

Why does this code not create Utility Shaders i can see in the Hypershade?


import maya.cmds as cmds

import mtoa.aovs as aovs



UtiD = cmds.createNode("aiUtility" , name="aiUtility_Red")

cmds.setAttr('aiUtility_Red.shadeMode' , 2)

cmds.setAttr('aiUtility_Red.color' , 1, 0, 0)


UtiD = cmds.createNode("aiUtility" , name="aiUtility_Green")

cmds.setAttr('aiUtility_Green.shadeMode' , 2)

cmds.setAttr('aiUtility_Green.color' , 0, 1, 0)


UtiD = cmds.createNode("aiUtility" , name="aiUtility_Blue")

cmds.setAttr('aiUtility_Blue.shadeMode' , 2)

cmds.setAttr('aiUtility_Blue.color' , 0, 0, 1)


UtiD = cmds.createNode("aiUtility" , name="aiUtility_Black")

cmds.setAttr('aiUtility_Black.shadeMode' , 2)

cmds.setAttr('aiUtility_Black.color' , 0, 0, 0)

----------------------------------------------------------------
https://linktr.ee/cg_oglu
7 REPLIES 7
Message 2 of 8

You need to do something like this:

import maya.cmds as cmds
UtiD = cmds.shadingNode("aiUtility" , name="aiUtility_RED", asShader=True) 




// Stephen Blair
// Arnold Renderer Support
Message 3 of 8

Thanks thats better now.

But i would need also the ShadingGroup. How do i get that?

----------------------------------------------------------------
https://linktr.ee/cg_oglu
Message 4 of 8

Here's another example: it creates a shader and a ShadingGroup, then assigns the shader to the selected objects


import maya.cmds as cmds
def assign_standard_surface():
    name = "aiStandardSurfac
    sel = cmds.ls(sl=True, l=Tru
    shader = cmds.shadingNode( 'aiStandardSurface', asShader=True, name=name )
    shadingGroup = cmds.sets( shader, renderable=True, noSurfaceShader=True, empty=True, name=name+"SG" )
    cmds.connectAttr(shader+".outColor", shadingGroup+".surfaceShader", force=True
    cmds.sets( sel, e=True, forceElement=shadingGroup )




// Stephen Blair
// Arnold Renderer Support
Message 5 of 8

Thanks for the Answer but the code doesnt work.

I tried to fix it but no luck. Sorry i have no experience in scripting at all.

----------------------------------------------------------------
https://linktr.ee/cg_oglu
Message 6 of 8

import maya.cmds as cmds
shader = cmds.shadingNode( 'aiUtility', asShader=True, name="aiUtility_RED" )
shadingGroup = cmds.sets( shader, renderable=True, noSurfaceShader=True, empty=True, name="aiUtility_REDSG" )
cmds.connectAttr(shader+".outColor", shadingGroup+".surfaceShader", force=True)




// Stephen Blair
// Arnold Renderer Support
Message 7 of 8

Thanks Stephen i got it working.


Just in case you wonder what im trying todo here are two little scripts to get an Object ID workflow running for Maya RenderSetup.

First you need to fire up the Python script to create the needed Shaders.
Afterwards load the JSON in the RenderSetup.

https://github.com/Mudoglu/Maya_Scripts


I will upload a Tutorial next week.

Cheers

----------------------------------------------------------------
https://linktr.ee/cg_oglu
Message 8 of 8

@ Great! If my answer helped, can you click Accept ? thanks



// Stephen Blair
// Arnold Renderer Support

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report