|10 October 2012||#1|
Join Date: Nov 2011
MEL Scripting Help
So I'm super new to MEL scripting (about a week into it), and any kind of coding in general. I'm working on 'baby' scripts right now to attempt to slowly build my knowledge and better understanding. I've been kind of copying, pasting and picking apart scripts and reading up on MEL and I've come up with this so far.
The questions I have right now are, for the 'Toggle All Normals Off/On' is there a way I can have it register an error in the command line if all the geometry objects aren't select? If you click on the button and all the geometry objects in the scene aren't selected, its errors.
The other is, for the Normal Size slider, is there a way to limit the amount of printed decimals in the command line? It's more of an aesthetic.
Also any other critiques, tips/pointers would be greatly appreciated!!
|10 October 2012||#2|
Join Date: Sep 2011
First of all, I must warn you, I'm not a good mel scripter myself. I'll try to help though.
For your first question, two ways of doing that (at least).
First, you can force the selection. Maybe the best way, the less the user does, the happier he is.
If you don't want to do it automatically, you can compare the visible objects in the scene and the current selection.
Actually, you only compare the size of two arrays, so if you have [pCubeShape1,pCubeShape2] in the first array and [pCube2,pCube3] in the second one, it returns true, although they are different.
for the second question, you could do something like this :
But I don't recommend you to show this feedback, rather useless.
For the third point, I'd tell you to be aware of the way of writing your code (tabulations, comments, etc.). This script is quite simple but already hard to read. Don't hesitate to declare long names variables ($selectedObj instead of $s). In a long script, it's much easier to write and, above all, to read. Try to adopt a kind of normalization in the variables (like: no upperCase for the first letter and an upperCase to seperate words). Try to be sure that your procs' name can't be redundant to avoid conflicts. In other words, find unique words (something like: global proc Tog_Norm_Selected () instead of just global proc Selected () ).
Hope it helps!
|10 October 2012||#3|
Join Date: Sep 2003
Thread automatically closed
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.
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|