Hi there,
just want to show how to create a shelf button that enable/disable the Render Stats option Primary Visibility of the selected shapes node. In this way with one click I can enable and disable objects that will be rendered .
First of all , the following scripts use pymel code , Pymel is an autodesk wrapper that enable to run C++ Maya API and Mel codes .
As Maya Features you can save script or command into a shelf button and using when you need it, for example if you need specific selection or you must to do repeating commands , you can select the code from the Script Editor and drag it to a Shelf you can save it as a button!
In the following code I’ll turn on/off the primary visibility of the render stats:
import pymel.core as pm #IMPORT PYMEL MODULE
#method
def SetRenderPrimary():
sel= pm.ls(selection=1)#get current selection
if len(sel) == 0: #if selection is empty (==0)
pm.confirmDialog(t='error', button = "Continue", message ="Select at least one Object!") #return a message
else:
for elem in sel: # for elements in selection
currentVis= pm.getAttr(elem+".primaryVisibility") #get current visibility
if currentVis==1: #if current visibility is 1 change the visibility to 0
pm.setAttr (elem+".primaryVisibility", 0)
else:#else change visibility to 1
pm.setAttr (elem+".primaryVisibility", 1)
SetRenderPrimary();#execute method