I wanna achieve this effect:when I select a model form my scene,and execute my script it will automatic spot ReferenceItem and select them in ReferenceEditor window.

33 views
Skip to first unread message

Eri

unread,
Nov 17, 2013, 12:34:51 PM11/17/13
to python_in...@googlegroups.com
Hi:

   Im stucking with a problem,I wrote a simple script to achieve a ruslet,but unfortunate it didn't going very well.So I really wanna u my pal help  me out!

   I wanna achieve this effect:when I select a model form my scene,and execute my script it will automatic spot ReferenceItem and select them in  ReferenceEditor window.

Show below:

import maya.cmds as cmds
import maya.mel as mel




def selMesh_toRefNode(selObject):
    re_referenceNode_name
=str()
   
if selObject !=None:
       
if cmds.referenceQuery(selectObject,isNodeReferenced=True):
            re_referenceNode_name
= cmds.referenceQuery(selectObject,referenceNode=True)
   
return re_referenceNode_name




def selRefNode_RefEditor():
   
if 'referenceEditorPanel1Window' not in cmds.lsUI(windows=True):
        mel
.eval('ReferenceEditor;')
   
try:
        selectObject
= cmds.ls(selection=True)[0]
        get_RefNode
= selMesh_toRefNode(selectObject)
   
except IndexError:
       
print 'No select'
    allRefNode_List
= cmds.ls(references =True)
   
RefNum = allRefNode_List.index(get_RefNode)
    mel
.eval('sceneEditor -e -selectItem '+ str(RefNum) +'$gReferenceEditorPanel;')




selRefNode_RefEditor
()


     Here the issue comes:If reference got very complicated,this litte script is not so useful.IMO,I wanna find all the items that referenced in my  scene in ReferenceEditor with PyQt.And treat all the items as string.So that I can easy use "mel.eval('sceneEditor -e -selectItem '+ str(RefNum)  +'$gReferenceEditorPanel;')" this little one to select there index number to get what I want.Right pal?

     Well,I know the way(maybe right maybe not),But I just cant get the right result.So,help me out of the circle Please!!!


Best Regards

EriLee

Asi Sudai

unread,
Nov 20, 2013, 2:09:30 PM11/20/13
to python_in...@googlegroups.com
You have a mistake in selMesh_toRefNode() where use both selObject and selectObject

import maya.cmds as cmds
import maya.mel as mel




def selMesh_toRefNode(selObject):
    re_referenceNode_name
=str()
    
if selObject !=None:

        
##
if cmds.referenceQuery(selectObject,isNodeReferenced=True):
        
##    re_referenceNode_name 
= cmds.referenceQuery(selectObject,referenceNode=True)
        if cmds.referenceQuery(selObject,isNodeReferenced=True):
            re_referenceNode_name 
= cmds.referenceQuery(selObject,referenceNode=True)
Reply all
Reply to author
Forward
0 new messages