在所有当前视图端口上循环

2024-06-02 04:24:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以在特定窗口中使用

modelEditor -e -nurbsCurves $b modelPanel3;

其中modelPanel3是所选的视口。你知道吗

如何对当前可见的所有视口执行此操作?是否有一个什么可以得到一个数组来返回这样的信息,或者您必须循环一个数字来查看viewport可见性是否为真?你知道吗


Tags: 信息数字数组viewport视口modeleditornurbscurvesmodelpanel3
1条回答
网友
1楼 · 发布于 2024-06-02 04:24:30

我会回答我自己的问题:

在视口中循环

# 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))

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

相关问题 更多 >