I started to study MEL to make my future life easier with scripting. I've studied C++ and C# in school and the logic is similar. Languages of course has their differences.
I got the basic script working, but I wanted to create window where to give the commands so no need to edit the code every time with new name.
This is the basic code which works just fine (I had the variables in finnish and changed those in english just in fly. Should work however)
Here is the code which should create a window where to type to textfield and no need to touch the code. However I get few errors and few are confusing me because before the window system those worked just fine. Here's the error messages:
// Error: string $Named = `ls -sl`; //
// Error: Syntax error //
// Error: for ($myNode in $Named) //
// Error: "$Named" is an undeclared variable. //
// Error: select $myNode; //
// Error: "$myNode" is an undeclared variable. //
Anyone who could help me? Thanks!
Btw, does anyone know any good script editor for mac which understands MEL?
A few things need to be corrected here. The first is the easiest: you forgot a semicolon after the string $NewName line. :)
Whenever you have a line that you know should work returning a syntax error, check the line before it for the semicolon.
Now, some of the flags on your interfaces commands are incorrect. Make sure you double-check flags in the help docs. textField controls don't have 'label' flags, but a textFieldGrp does. The flag for the actual text field is 'text,' not 'field' or 'value' (so when you query it, use '-q -text' not '-q -value').
Also, when you query that text field, you need to specify which text field you're referring to, which means you need to capture its name. This is a very common technique useful in all sorts of scripting tasks. When you create your text field, capture its name like this:
string $myFieldName = `textField -tx "New name"`;
Now the string $myFieldName will refer accurately to that particular text field.
Give those suggestions a try and post again if you have more questions. Good luck.
Sorry, I've been busy away so I havent had any time to develop this script.
Now I finally tried to finish this script to make it easy to use everyday tool. However I still crashed weird problem. It opens window where is that requested textfield (for some reason there's number one there) and that button which says Rename.
When I type new name and press rename button it gives name like this: RenamerWindow_columnLayout27_textField10
Here's the updated code. I added also added that if statement to the beginning to prevent Objects name is not unique error:
If it's not moving, animate it