开发者

Maya API - Create plugin to import various Models

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 diffe开发者_开发技巧rent 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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜