遍历所有当前视口

Loop over all current view ports

我可以使用

在特定 window 中关闭 NURBS 视图
modelEditor -e -nurbsCurves $b modelPanel3;

其中 modelPanel3 是选择的视口。

如何为当前可见的所有 个视口执行此操作?是否有什么可以获取 return 这样的信息,例如数组,或者您是否必须循环遍历一个数字并查看视口可见性是否为真?

那我来回答我自己的问题:

循环浏览视口

# import python maya commands 
 import maya.cmds as cmds

# Create a list of ALL viewports
viewports = cmds.getPanel( all = True)

# Get the current viewport
vp = cmds.getPanel( withFocus = True) # current viewport
current = cmds.modelEditor( vp, q = True, nurbsCurves = True)

for view in viewports:
  if 'modelPanel' in view:
  # check to see if the item in lists is a viewport
  # is one of the model panels.
  # The list is quite big and we only need up to four

    print view # prints the current viewport

    #Swap the NURBS visibility around
    cmds.modelEditor( view, edit = True, nurbsCurves = not(current))

我希望这对我和你一样有帮助。是的,它确实。谢谢