Mel Import Command Documentation?

Mel Import Command Documentation?

Anonymous
Not applicable
1,646 Views
2 Replies
Message 1 of 3

Mel Import Command Documentation?

Anonymous
Not applicable

Hi Guys,

i would like to open the import window with mel.

So far so good. It works with just "Import;"

Now i would like to open that window with a specific folder and a selected File Filter.

But there is no documentation. The Import Command is not documentated, but it exists.

Anyone knows?

 

Cheers

Sebastian

0 Likes
Accepted solutions (1)
1,647 Views
2 Replies
Replies (2)
Message 2 of 3

clemensF4NFT
Participant
Participant
Accepted solution

Sebastian,

Import is a runtime command as you can see by typing

whatIs Import;

It executes the projectViewer command as you can find out by typing

runTimeCommand -q -command Import;

You can look into the projectViewer script that resides here:

whatIs projectViewer;

The Import portion of this script can be configured only by setting the defaultFileImportType option variable
and by setting the working directory.
But the projectViewer script configures the fileDialog2 itself.
So the most flexible approach is to configure fileDialog2, too, like projectViewer does but with your own values.
After calling the dialog you have to run the same lines of code like in projectViewer.mel.
In the end your custom import script might look like this:

preCheckColorManagement();
string $myImportFolder = "/my/predefined/import/folder";
string $file[] = `fileDialog2 -returnFilter 1 -caption "Import" -fileMode 1 -okCaption "Import"
 -optionsUICreate "fileOperationsOptionsUISetup Import"
 -optionsUIInit "fileOperationsOptionsUIInitValues Import"
 -selectionChanged "fileOperationsSelectionChangedCallback Import"
 -optionsUICommit2 "fileOperationsOptionsUICallback Import"
 -fileTypeChanged "setCurrentFileTypeOption Import"
 -fileFilter "Maya Scenes (*.ma *.mb)"
 -selectFileFilter "Maya Scenes"
 -startingDirectory $myImportFolder
 -optionsUICancel "fileOptionsCancel"`;
int $len = size($file);
if( $len > 0 && $file[0] != "" )
{
    string $path = fromNativePath($file[0]);
    string $type = filterDescriptionToFileType($file[$len-1]);
    eval ("performFileAction \"" + $path + "\" Import \"" + $type + "\"");
}
checkForUnknownNodes();
checkColorManagementMissingColorSpaces();

All best wishes

Clemens

Message 3 of 3

Anonymous
Not applicable

Meanwhile i have made another solution with filedialog2 and file -import.

Meanwhile i know what runtime commands are and that is much more complex than just doing some mel commands.

I will try your solution and thanks for the detailed explanation.

 

cheers

0 Likes