Looks at the Smooth Mesh preview state of all selected items (i.e. keyboard shortcut '1','2', or '3') and automatically sets the Octane SubD on or off to match an object's smooth mesh state. A whole lot easier than manually sorting through dozens of objects...
Defaults to a subD level of 3, but you can change that by editing the value in the second line of the script.
Note: Calus' script a few posts back does the same thing via an expression link, which is cool; I just wanted to create a one-click shelf tool that I could update manually without inadvertently changing Octane settings while tweaking in the Viewport 2.0 renderer.
- Code: Select all
import maya.cmds as cmds
octSubDLevel = 3
def setOctaneSubd(objList=None):
global octSubDLevel
for curObj in objList:
#attrExist = maya.cmds.attributeQuery('displaySmoothMesh', node=curObj, exists=True)
cmdStr = curObj + '.displaySmoothMesh'
subDState = cmds.getAttr(cmdStr)
cmdStr = curObj + '.octSubdLevel'
if subDState == 0:
cmds.setAttr(cmdStr, 0)
else:
cmds.setAttr(cmdStr, octSubDLevel)
sel = cmds.ls(sl=True, dag=True, type="mesh", long=True)
if sel:
setOctaneSubd(sel)