Maya API - 创建插件以导入各种模型

发布于 2024-10-31 09:08:06 字数 158 浏览 0 评论 0原文

我正在尝试在 Maya API 中创建一个插件,该插件基本上在 Maya 内部有一个菜单,并且我将能够根据按下的按钮加载不同的角色头。

这是我第一次使用 Maya API,所以我很陌生。

关于如何使用 API 导入此类模型有什么想法吗?

非常感谢! 泰勒

I am trying to create a plugin in Maya API that will basically have a menu inside of Maya and I will be able to load in a different character head depending on which button was pressed.

This is my first time with the Maya API so I am quite unfamiliar.

Any ideas on how to import models like this using the API?

Thanks so much!
Tyler

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹤舞 2024-11-07 09:08:06

我建议使用 MEL 作为开始,而不是 Maya API。
您应该查看的 MEL 命令是用于导入文件的 file进入您的场景(例如头部),可能还有所有 UI 相关命令< /a> 创建一个简单的窗口。

I recommend using MEL as a start, instead of the Maya API.
MEL Commands you should look at are file to import files into your scene (e.g. heads), and probably all UI related commands to create a simple window.

三月梨花 2024-11-07 09:08:06

正如 Byron 提到的,MEL 或 Python 脚本将是比使用 API 更简单的解决方案。与使用脚本相比,使用 API 能够完成的任务有一个关键区别:

使用 OpenMayaUI 模块,您可以将“头部选择 UI”直接插入到 Maya 中的现有菜单中。

使用脚本,您只能使用一个浮动 ui 窗口,该窗口可以停靠在 Maya UI 中的某些位置(这在技术上是不正确的,但是以这种方式使用脚本比尝试将脚本强制进入 UI 要容易得多)。此外,为要在 Maya 中启动的脚本创建按钮需要脚本用户执行额外的步骤。它无法为他们“安装”到 Maya 中(同样,这在技术上并不正确,但大多数用户更喜欢架子按钮而不是 UI 中的菜单)。请参阅 Autodesk 文档:创建脚本的架子按钮以获取更多信息。

我认为脚本不足以完成简单的头部交换操作,但如果您希望将其用作学习 API 的练习,那么我可以给您一些指导:

首先,所有非 API Maya 命令可以通过脚本和使用插件 API 进行访问。由于此“插件”除了将插件直接添加到 UI 所需的模块之外不需要任何 API 模块,因此您可以使用脚本模拟整个功能。

换句话说,您可以在脚本和插件中使用“import maya.cmds as cmds”,并且您想要的实际功能完全可以使用该模块来实现。因此,我建议您首先制作一个执行您想要的操作的脚本,然后将该脚本转换为插件。一旦您已经有了一个可以运行的脚本,创建一个实现此结果的命令插件应该相当简单。然后,您需要做的就是使用 UI API 模块将菜单添加到现有的 Maya UI。

脚本完成后,以下是 Autodesk 关于创建命令插件的教程的链接: Autodesk Python API 文档

此 cgsociety 讨论包含许多在 Maya 中获取 UI 的有用技巧(讨论是关于 C++ 的,但相同的概念也适用于 Python 插件): C++ 将菜单添加到 Maya 的主菜单栏

我已经假设这会所有这些都可以使用 Python 完成,因为脚本和插件都可以用该语言进行编程。这也是我使用的——我从未深入研究过 C++ API。无论如何,我希望这会有所帮助!祝你好运 :)

As Byron mentioned, MEL or Python scripting would be a (dramatically) simpler solution than using the API. There is one key difference between what you will be able to accomplish using the API compared to a script:

Using the OpenMayaUI modules, you can insert your "head selection UI" directly into the existing menus in Maya.

Using a script, you are restricted to a floating ui window that can be docked in certain places in Maya's UI (This is not technically true, however it is far easier to utilize scripts in this manner rather than trying to force your script into the UI). Furthermore, creating a button for the script to be launched in Maya requires users of the script to take an extra step. It cannot be "installed" into Maya for them (Again, not technically true, but most users prefer shelf buttons as opposed to menus in the UI). See Autodesk Documentation: Creating a shelf button for a script for more information on that.

I see no reason that a script will not suffice for a simple head swap action, but if you wish to use this as an exercise in learning the API then I can give you a few pointers:

First of all, all non-API Maya commands can be accessed in both a script and using the API for a plugin. Since this "Plugin" does not require any API modules other than those needed for adding the Plugin directly to the UI, you can mockup the entire functionality using a script.

In other words, you can use "import maya.cmds as cmds" in both a script and a plugin, and the actual functionality you desire is available entirely using that module. Therefore, I would advise you make a script that performs the actions you want first, then work on converting that script into a plugin. Creating a command plugin that achieves this result should be fairly simple once you already have a script that works. Then, all you need to do is use the UI API modules to add your menu to the existing Maya UI.

Once your script is complete, here is a link to Autodesk's tutorial on creating a command plugin: Autodesk Python API Documentation

And this cgsociety discussion contains a lot of useful tips of getting your UI inside of Maya's (the discussion is about c++, but the same concepts apply to python plugins): C++ Add Menu to Maya's Main Menu Bar

I've taken to assuming this will all be done using Python, since scripts and plugins can both be programmed in that language. It's also what I use- I've never delved into the c++ API. Anyways, I hope this helps! Good luck :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文