简体   繁体   English

Maya python命令到Maya api:modelEditor设置

[英]Maya python commands to Maya api: modelEditor settings

I'm trying to switch active 3d view with desired settings on while using the python API instead of the Maya python commands. 我正在尝试在使用python API而不是Maya python命令的同时使用所需设置打开活动3d视图。 Which API functions should I use? 我应该使用哪些API函数?

Python command gives me the desired result: Python命令给了我想要的结果:

import maya.cmds as cmds

editor = 'modelPanel4'
cmds.modelEditor(editor, edit=True, displayAppearance='smoothShaded', nurbsCurves=True, nurbsSurfaces=True, polymeshes=True, textures=True, useDefaultMaterial=False, backfaceCulling=False, displayTextures=True, grid=False)

I am trying to get the same result using the Maya Python API but cannot find the suitable functions. 我正在尝试使用Maya Python API获得相同的结果,但是找不到合适的函数。

import maya.OpenMayaUI as omui

view = omui.M3dView.active3dView()
#displObj = view.objectDisplay()
view.setObjectDisplay(7)
#displStyle = view.displayStyle()
view.setDisplayStyle(2)
#displTexMode = view.textureMode()

Can anyone help me? 谁能帮我?

Just use the python code you started with. 只需使用开始的python代码即可。 Historically Maya has always been designed with a very clear separation: 从历史上看,Maya始终设计得非常清晰:

  • The GUI is written in MEL (although you can do that in python now) GUI用MEL编写(尽管您现在可以用python编写)
  • The computation of a node (and GL rendering) is written in C++ (or the python API) 节点(和GL渲染)的计算是用C ++(或python API)编写的

If you are hoping that you can find an API equivalent for a GUI method, you are out of luck. 如果您希望可以找到与GUI方法等效的API,那么您很不走运。 There are a few GUI classes within the API, but they are specifically there to help add custom GUI tools and manipulators. API中有一些GUI类,但是它们专门用于帮助添加自定义GUI工具和操纵器。 They aren't there to help manipulate the existing GUI, for that you'll need to use the python (or MEL) commands as you did in the first code snippet. 它们不是用来帮助操作现有GUI的,因为您将需要像在第一个代码片段中一样使用python(或MEL)命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM