SCRIPT: Match Octane SubD to Smooth Mesh preview state

Sub forum for help and tutorials.

Moderator: JimStar

Post Reply
pixerati2
Licensed Customer
Posts: 42
Joined: Sun Jul 06, 2014 4:06 pm

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)
Last edited by pixerati2 on Mon Jun 10, 2019 5:19 pm, edited 1 time in total.
pixerati2
Licensed Customer
Posts: 42
Joined: Sun Jul 06, 2014 4:06 pm

Edited the above script to check for meshes only; previously it would have given you an error if you had non-mesh objects selected.
Post Reply

Return to “Help / Tutorials”