Hotkey for Assign material?

JacksonLamme
Advocate
Advocate

Hotkey for Assign material?

JacksonLamme
Advocate
Advocate

I have hundreds of materials in my scene and rightclicking then going to arnold and shimmying down to AIsurface takes too long.  Is there a faster way?  

 

Many thanks

0 Likes
Reply
Accepted solutions (1)
1,063 Views
5 Replies
Replies (5)

Kahylan
Advisor
Advisor

Hi!

 

I'm not quite sure, are we talking about new materials or existing materials?

 

if it is just a question of creating new materials, you can use a script like this one to do so:

import maya.cmds as mc

sel = mc.ls(sl = True)

for s in sel:
    
    mat = mc.createNode("aiStandardSurface", n = "{0}_material".format(s))
    sg = mc.createNode("shadingEngine", n="{0}_SG".format(s))
    mc.connectAttr("{0}.outColor".format(mat), "{0}.surfaceShader".format(sg))
    shape = mc.listRelatives(s, s= True)[0]
    attr = mc.listConnections("{0}.instObjGroups[0]".format(shape), p = True)[0]
    mc.disconnectAttr("{0}.instObjGroups[0]".format(shape),attr)
    mc.connectAttr("{0}.instObjGroups[0]".format(shape),"{0}.dagSetMembers[0]".format(sg))

 

If you need to connect the right existing materials with their geometric counterparts, it is going to be harder, because you would need very strict consistent naming conventions to write a script that does that.

 

I hope this helps!

0 Likes

JacksonLamme
Advocate
Advocate

Thank you! I'm not sure what that does, does in make control or s the hotkey?  What about just a new AIstandard surface?

0 Likes

damaggio
Mentor
Mentor

I agree with Kahylan,  your question is hard to understand Jackson. Maybe you can gives a better description.

0 Likes

JacksonLamme
Advocate
Advocate

I only usually create ai standard surface,  but I have to click 3 times and find it in a long list every time,  when I would prefer to just default to having an ai standard surface on my materials.   I've searched for this for quite a while and not so cut and dry

0 Likes

Kahylan
Advisor
Advisor
Accepted solution

If that is what you want then I understood you correctly, you can just create a hotkey that runs the script that I posted above using the hotkey editor. This should give you the result you want.

 

Here's a tutorial on creating and assigning custom hotkeys

https://www.youtube.com/watch?v=3Xhnnao6AXY