Select and hide multiple USD prims in maya

404 views Asked by At

Im working with usd in maya and Im notice that the cmds.ls(sl=True) doesn't work as ussualy with usd prims or transforms, if you select something in the outliner and run cmds.ls(sl=True) it returns nothing. I see that only return the selected top Group.

So I made this script to get the selected "mesh" from the outliner, because I see that usds needs the stagepath and the sdfpath so I can do things to that object.

My problem is that with this script I can only apply it to one object at a time, because if I select several things in the outliner, it only takes into account the first selection, and the rest do not appear. I can't use a loop because there is no lists or selections that I can use. Any ideas?

This is the script for make invisible a usd object:

from mayaUsd.lib import proxyAccesor as pa

stagePath, sdfPath = pa.getSelectedDagAndPrim()
prim = (stagePath + ',' + sdfPath )
cmds.setAttr(prim + ".visibility","invisible")

Thanks!

outliner with usds selected

1

There are 1 answers

0
jaimex127 On

I finally get the way to hide multiple prims in maya.

import maya.cmds as cmds
 
proxy_prim_path = cmds.ls(sl=True, ufe = True)
   
for prim in proxy_prim_path:
    cmds.setAttr(prim + "visibility","invisible")


ufeObjects (ufe) will return objects that are defined through the UFE interface as well as native Maya objects.