View Full Version : Requesting a MEL script: regarding menus/options
paladinsword 02-18-2007, 11:03 AM Dear members,
Of late, I have been meddling with MEL scripting in order to improve my workflow. I made around six to eight scripts, which speed up my modelling process and let me go through the interface a lot faster than would normally be possible. Now, I am looking to expand my repetoire of MEL scripts and I have hit a rather irritating roadblock. Before I describe the problem, you ought to know a few things about me:
1. I am NOT a programmer.
2. I stop understanding code when the loops and conditions begin.
Point number 2 might be a bit of an exaggeration, but they are pretty much an accurate description of my programming skills. Now here is my problem:
I have created some scripts which make Maya prepare models for me without having to sit and model simple objects again and again. Unfortunately, the number of such scripts is growing fast and that means - cluttered shelves with lots of scripts.
I want to simplify my workflow by creating menus/options - something like the ones that appear in the attribute editor. Here is a description of what I want:
1. User clicks a button in his shelf.
2. The attribute editor opens.
3. There are some radio buttons in the newly opened attribute editor window.
4. User clicks on one of the radio buttons.
5. The script, attached to the clicked radio button, executes.
Could someone help me make such a script? I would appreciate any help in this regard, as such scripts would make my life with Maya extremely easy. Thanking you,
With regards and best wishes,
Jaidev. K
P.S: Please explain the steps, if possible, in detail. I would like to understand the code thoroughly so that I can adapt it for other, possibly more complex, menus.
|
|
ManuelM
02-19-2007, 12:24 PM
i wrote something similar... check it out:
http://www.manuelmacha.de/scripts/mmListMelScripts.mel
description of how it works is here:
http://www.manuelmacha.de/scripts/scripts.html#mmListMelScriptsAnchor
cheers,
m.
paladinsword
02-19-2007, 04:48 PM
Dear Manuel,
Thank you very much for the links. :) I downloaded your instancing, aligning and script accessing scripts. They will prove to be VERY useful to me, I am sure. :thumbsup: I can already imagine quite a number of uses for these scripts in my workflow. Thank you once again. :)
With regards and best wishes,
Jaidev. K
---
Dear members,
Manuel's scripts helped a lot, but I am still having difficulty finding scripts that use the attribute editor. Does anyone know how to use the attribute editor in a manner similar or pretty much like the way I described in my first post? (To make a menu/option box, etc...)
Tomorrow, I'll most probably take a look at some of Maya's .mel scripts in the program folder. I am sure there are quite a few scripts that access the attribute editor in some way.
Regardless, any help you all can provide me in this regard will be VERY helpful.
Thanking you,
Jaidev. K
ManuelM
02-20-2007, 02:14 AM
why does this need to happen in the attribute editor?
the attribute editor is programmed to list and manipulate objects' attributes - not to launch mel-scripts.
having said this, it's still no problem at all to script a window, that looks and feels exactly like the attribute editor, but which also offers the ability to do whatever you wish. it's just quite a bit of work...
Mikademius
02-20-2007, 08:29 PM
Right now I do not have time to write it for you like I normally would, but I wanted to let you know that I have written a 6 page mel tutorial that might interest you. It goes from VERY BASIC to a bit advanced :)
http://www.final3.com/html/tutorials/mel_ShapeEditor_01.htm
paladinsword
02-21-2007, 03:18 PM
Dear Mikademius,
Thank you very much for the tutorial link. I already saved all 6 pages of it and will be going through it. Lots of work creeping up on me and hence, I find myself trying to simplify my workflow even more. :)
Once again, thank you very much for the tutorial. Nice to see so many helpful people here. :thumbsup:
---
Dear Manuel,
It is always better to adapt what is already available than to make something new everytime. Maya uses the attribute editor to change settings of many tools like Create EP Curve tool. The options for changing the settings of these tools appear in the attribute editor as much as they do in the tools' option boxes.
As a matter of principle and efficient working habits, I prefer to work with things that exist instead of trying to chisel something from a new boulder everytime I need to adapt. My skill level is pretty mediocre and I can't really adapt whatever I see, but things improve with time and practice. :)
Of course, I am always willing and eager to learn. So please fire away with any suggestions and tips that you may have. I would certainly like to hear them. :thumbsup:
With regards and best wishes,
Jaidev. K
Pyoeter
02-28-2007, 03:17 AM
From my limited mel knowledge I would say it is way easier to just pop up a new window and add some radio buttons to it than trying to figure out how you can add controls to the attribute editor.
if (`window -exists MyWindow`)
{
deleteUI -window MyWindow;
}
string $window = `window -title "Object Maker"
-iconName "Short Name"
-widthHeight 200 40 MyWindow`;
columnLayout -adjustableColumn true;
radioButtonGrp -numberOfRadioButtons 3
-label "Available Objects" -labelArray3 "make Sphere" "make cube" "make torus"
-onCommand1 ("CreatePolygonSphere;")
-onCommand2 ("CreatePolygonCube;")
-onCommand3 ("CreatePolygonCylinder;");
button -label "Close" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;
goleafsgo
02-28-2007, 12:54 PM
When you say "Attribute Editor" I think you really mean "Tool Settings Window".
The tool settings window is there to hold options for the current tool. Like the Select tool, Move tool, Rotate tool, EP Curve tool...
If you want to put something in the tool settings window then you have to have an actual tool...then when you make it active it's MEL script for creating the settings will get called. If you have a bunch of MEL scripts that you are using then those settings won't go into that window.
The main option box is different. It is to hold options for commands, not tools. That is most likely where you want to put your settings. If you really want to put your settings into the main option window then I could point you in the right direction. But like others have said you might as well just make your own window. At least get that part working correctly and then putting your controls into the "real" option window is only a few lines of code.
paladinsword
02-28-2007, 02:26 PM
Dear Pyoeter,
THANK YOU! :) Those lines of code really boosted my knowledge of MEL by a cannon's range, maybe more. :thumbsup: Thank you very very much.
---
Dear goleafsgo,
The Tool Settings Window, is it? I am sorry for getting the term wrong. I really should have checked the names again. Sorry about that. :sad:
It is not that I am addicted to the Tool Settings Window or anything. I really have no problems in learning to code my own windows. It is just that, as I mentioned in my previous post, I like to know how to adapt the application to suit my needs, instead of trying to create something new each and everytime. :smile:
Besides, I have taken this saying to heart and turned it into one of my working principles: "Always try to have 10 different ways to do something. That generally makes sure 1 of them works for you. :wise:"
So, could you kindly 'point me in the right direction', as you mentioned earlier? I would appreciate it a lot. Who knows where I could go with those extra lines of code? :smile:
---
Since we are pretty much into MEL script in this thread, with regard to my problems that is, allow me to ask a couple of questions that have been 'bothering' me, to say the least.
1. While using Maya 8™, at my graphics institute, I come across a certain bug while applying materials. Everytime I apply an image file to the 'Color' attribute of a material, Maya creates a projection map and two extra nodes all on its own. This basically screws up the entire thing.Is this a bug in Maya 8? I am thinking of writing a script to get by the bug, but do I need to do so? Is there some fix for this bug, or shall I go ahead with the scripting task to get around it?
2. Having created my personal 'Armory' (Shelf) of favourite tools and scripts, I want to carry the shelf, and everything in it, with me wherever I go. This way, I can work on any computer, anywhere, without having to setup my tools again and again... and again.:scream: After all, it is such a 'wonderful' thing to do repeatedly in one's 3D career. :rolleyes:
Now, I went into the preferences directory that Maya creates in C: - the same directory that contains user preferences, layouts, custom shelves, etc. I copied my shelf, along with my personal preferences, onto my IPod and loaded my shelf at my institute.
Important Note: I have Windows 2000 Professional™ installed in my PC at home. My institute has Windows XP™ installed on all their computers. (I am not sure if that XP is professional or the home edition, but I might say home edition as pure, ignorant guesswork.)
Anyways, when I loaded up my shelf on my institute's computer, I found that none of the script icons (the bitmaps assigned to my custom MEL script buttons) were being displayed.
Another Note: Each icon was made in Adobe Photoshop CS™ as a 30X30 .BMP file and saved that way. They display fine on my home PC and are stored in the C: Maya preferences directory in the Icons folder.
I tried to apply the icon images again, manually, through the Shelf editor, but Maya was not acknowledging the icon files as valid images. I could view the images with Windows™ Explorer, but Maya refused to accept them.
Reminder: The icon images work just fine on my home PC, which has Maya™ 7. The PC I tried the icons on, at my institute, also had Maya 7™.
Is there anyway I can get Maya to display the icons properly? Is there some problem with Windows XP with regard to recognizing bitmap files or icons?
Is there anyway I can write a script which directs all the scripts in my Shelf to search a particular directory on my USB drive for their icon images? Even specifying a specific file path would be very useful in the script.
Could anyone help me in this regard? Thanking you profusely in advance,
With regards and best wishes,
Jaidev. K
Buexe
03-04-2007, 05:47 PM
Check the docs for adding a "module" to Maya, which is basically a folder containing 3 subfolders: scripts, icons, plug-ins. You can have a module on your USB drive and have Maya load the stuff in there. Just make sure the Stick is connected to the computer before starting Maya and the path name is correct in the module declaration file.
CGTalk Moderation
03-04-2007, 05:47 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.