Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Using a translate on a variable in MEL?
  RSS 2.0 ATOM  

Using a translate on a variable in MEL?
Rate this thread
 
55091
 
Permlink of this thread  
avatar
  • zapfoe
  • Posted: 27 April 2011 11:51 PM
  • Total Posts: 3
  • Joined: 11 April 2010 10:17 PM

Hi,
Before anything else I would like to say that this is my 4th day of having a crack at MEL-script and probably need a lot more help than I’m asking for right now. But here we go…

I want to define the selected object in my scene as a variable. As far as I understand it’s done like this:

string $object = `ls -sl`;

This works so far.
My next step is to create a UI with a slider to control the translation of the object. This is what I’ve found so far.

window -title “sliderTest”;
columnLayout;

attrFieldSliderGrp -label “Translate X”
-min -10.0
-max 10.0
-fieldMinValue -100.0
-fieldMaxValue 100.0
-at “pSphere1.tx”;
showWindow;

This works great when the object name is specified but not when I use the variable $object instead. This is the error I get.

// Error: Invalid redeclaration of variable “$object” as a different type. //

I’m sure I’m doing it completely wrong and would appreciate absolutely any help I can get.

Thanks.



Replies: 0
avatar
  • THNKR
  • Posted: 28 April 2011 07:45 AM

string $objects[] = `ls -sl`;
string $temp;

window -title "sliderTest";
columnLayout;
for (
$temp in $objects){
    attrFieldSliderGrp 
-label ($temp " Translate X" )
        -
min -10.0
        
-max 10.0
        
-fieldMinValue -100.0
        
-fieldMaxValue 100.0
        
-at ($temp ".tx");
}
showWindow
;


Replies: 1
/img/forum/dark/default_avatar.png

thank you sir. this helped a lot.

Author: zapfoe

Replied: 01 May 2011 08:20 PM