Hi all
I'm working on a group project where we need to create a tool using python in Maya 2012. We've decided to create a tool that creates a polyCube based on several input fields (name, height, width, depth) and which features an "export" button that can be used instead of having to click on the "file" dropdown menu.
Unfortunately I'm a scripting noob (not to mention that for me, scripting is even more abstract than math), and I have no idea where to even look in order to accomplish this task.
Does anyone have any suggestions? I have tried various google searches but haven't come up with anything.
![:\ :\](https://polycount.com/plugins/emojiextender/emoji/twitter/confused.png)
Thanks in advance!
SOLVED: This is it. one stinking line of code, haha:
cmds.button(label='Export', command=cmds.ExportSelection)
Replies
Creating a script like this in Maya is pretty simple. You want to create a polycube so lets look at the documentation for a cube.
http://download.autodesk.com/us/maya/2011help/CommandsPython/polyCube.html
So if you have maya open. Run this:
A polycube should appear in Maya. If you look at the documentation, you can provide inputs so replacing maya.cmds.polyCube() with
That should give you a box that has its height as 10 width as 10 and depth as 10. Where did I get these attributes? By looking at the documentation and the associated flags and also you can see this from watching the script editor listener. This should be your two spots for constant reference. One thing to note, maya spews all its info out as mel commands so you're gonna have to convert it to python equivalent. There is maya2py script but I haven't messed with it.
This is in bare essence what you're making. All you need to do is make variables that co-relate to the attributes and assign them to the attributes instead of hard-coded values.
As an example
Hopefully gives you enough to go on. Good luck and don't be scared of code
We've already got the part of the script that creates the cube running. We've got a button on our GUI that is labelled "Export" and we need that button, when pressed, to open up the "export selection..." dialogue box. That's what we're currently trying to figure out.
But thanks all the same for your quick response
Did some looking into fileDialog2 and pretty simple.
and filename will be returned as the path to where it needs to be saved.