MEL - Pass User Input into a variable


Hello everyone,

I am a little stuck with user inputs.

I am trying to create a window where the user can write the name of the fbx they want to import then pass it on to the string that contains the file path to open that fbx. I have tried different combinations but I getting only errors. I thought I was closed, but I cant seem to understand how to pass the string variable.


if(window -exists expWindow){

deleteUI expWindow;


//Create Prompt Dialog Window…

string $userInput = promptDialog -t "Anim Import" -message "File Name" -button "Process";

//If button is clicked, run the following commands…

if ($userInput == “Process”){

//Query the text in Prompt Dialog’s name field…

string $userInput_text = promptDialog -q -text $userInput;

//Import FBX File with the specified namespace.

$myFilePath = “D:/Desktop/Animations” + $userInput + “.fbx”;

file -import -type “FBX”

-ignoreVersion -ra true -mergeNamespacesOnClash false

-namespace $userInput -options “fbx” -pr -importFrameRate true

-importTimeRange “override” $myFilePath;


But I get one warning and one error:

// Warning: Line 5.91 : Redeclaration of variable “$userInput” shadows previous declaration at line 1. Previous value will be overwritten by explicit initializer. //

D:/Desktop/Animations/Process.fbx// Error: line 21: File not found. //

I don’t know why it is printing Process. I thought I was close but I can’t figure out how to pass on the user input to the end of the string.


Sorry, guys. I was able to catch my error. I was using $userInput instead of $userInput_Text. But I am still getting the warning issue.