Trying to connect an object with a shading group in Maya

User Generated

Nahovfcs

Programming

Description

How do I create two scrolllists with one being objects in scene and other being shading groups.allow user to select one from each and connect them when button is pressed
import maya.cmds as cmds
def GUI():
  winName="myWindow"

  if ( cmds.window(winName,exists=True)):
  cmds.deleteUI(winName)
   
  cmds.window(winName,title='mesh/shader connector',w=200,h=500)
  cmds.window(winName,q=True,wh=True)
 
  cmds.rowLayout("obj,shd",nc=2,w=200,h=200)
  cmds.columnLayout( adj=True, columnAttach=('left', 5), rowSpacing=10, columnWidth=250 )
  cmds.textScrollList('obj')
  cmds.textScrollList('shd')  
  cmds.textFieldButtonGrp('obj',bl='Import Object', text='Select Object',ed=False, bc='selMultipleObjects()')
  cmds.textFieldButtonGrp('shd',bl='Refresh Shaders', text='Refresh Shaders',ed=False, bc='shadeGrps()')
  cmds.button('Connect()',l='Connect')
  cmds.showWindow()

GUI()

def selObjName():
  sel=cmds.ls(sl=True)[0]
  cmds.textFieldButtonGrp('obj',e=True,text=sel)
   
   
def selMultipleObjects():
  sel=cmds.ls(sl=True)
  cmds.textScrollList('obj',e=True,ra=True)
  cmds.textScrollList('obj',e=True,numberOfRows=len(sel)+10, allowMultiSelection=True,
       append=sel)

def shadeGrps():       
  Shader=cmds.ls(mat=True)
  cmds.textScrollList('shd',e=True,ra=True)
  cmds.textScrollList('shd',e=True,numberOfRows=10,append=Shader)

def Connect():
  cmds.shadingConnection( 'shd', e=True, cs=0 )
  cmds.shadingConnection( 'obj', q=True, cs=True )

   
 



   
  the connect button doesn't work... any alternate way of doing this?


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Related Tags