我已经编写了一个脚本,用于切换活动视口并隔离所选的'特征。为什么这似乎没有隔离选定的对象?我的方法似乎是正确的,但我在某处遗漏了某些东西,而我似乎无法确定它究竟是什么。
import maya.cmds as cmds
viewports = cmds.getPanel( type='modelPanel' )
curPanel = cmds.getPanel( withFocus=True )
if curPanel in viewports:
curState = cmds.isolateSelect( curPanel, q=True, state=True )
notState = not curState
if notState:
cmds.isolateSelect( curPanel, addSelected=True)
cmds.isolateSelect( curPanel, state=notState)
FIXED:
import maya.cmds as mc
import maya.mel as mel
isoPnl = mc.getPanel(wf=True)
isoCrnt = mc.isolateSelect(isoPnl, q=True, s=True)
mel.eval('enableIsolateSelect %s %d' % (isoPnl,not isoCrnt) )
答案 0 :(得分:0)
您的代码正确切换隔离视图的开启和关闭,但是将选定的对象添加到该视图无效,这就是为什么它会为您提供一个空视口
要添加所选对象,命令为:
cmds.isolateSelect(modelPanel, addSelected=True)
当notState
为真时,最合乎逻辑的是运行该命令:
if curPanel in viewports:
curState = cmds.isolateSelect( curPanel, q=True, state=True )
notState = not curState
cmds.isolateSelect( curPanel, state=notState)
if notState:
cmds.isolateSelect(modelPanel, addSelected=True)