Page 1 of 1

SCRIPT: Match Octane SubD to Smooth Mesh preview state

Posted: Tue Jun 04, 2019 12:56 am
by pixerati2
Super simple, but I didn't see any Octane native function:


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)

Re: SCRIPT: Match Octane SubD to Smooth Mesh preview state

Posted: Tue Jun 04, 2019 6:16 pm
by pixerati2
Edited the above script to check for meshes only; previously it would have given you an error if you had non-mesh objects selected.