Home Coding, Scripting, Shaders

Maya MEL how to put name into fileDialog2 options box when the window opens.

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
I'm trying to launch a export selection dialog box, but I'd like to grab my selected objects name and store that in a variable and then have that auto pasted when the dialog appears. I can't find this in the docs, is it possible. This is what I have so far, all the options are set, but I also want to set a name so the user doesn't have to type it.

$tbSaveLocation = `fileDialog2 -ff "*.fbx"`;
FBXProperty Export|IncludeGrp|Geometry|SmoothingGroups -v false;
FBXProperty Export|IncludeGrp|Geometry|expHardEdges -v false;
FBXProperty Export|IncludeGrp|Geometry|TangentsandBinormals -v false;
FBXProperty Export|IncludeGrp|Geometry|SmoothMesh -v false;
FBXProperty Export|IncludeGrp|Geometry|SelectionSet -v false;
FBXProperty Export|IncludeGrp|Geometry|BlindData -v false;
FBXProperty Export|IncludeGrp|Geometry|AnimationOnly -v false;
FBXProperty Export|IncludeGrp|Geometry|Instances -v false;
FBXProperty Export|IncludeGrp|Geometry|ContainerObjects -v false;
FBXProperty Export|IncludeGrp|Geometry|Triangulate -v false;
FBXProperty Export|AdvOptGrp|Fbx|AsciiFbx -v "Binary";
FBXExport -f test $tbSaveLocation -s;

Replies

  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Found the answer after searching further, sharing for others that find this thread. use the -dir flag.

    $tbSaveLocation = `fileDialog2 -dir "c:/test.fbx" -ff "*.fbx"`;
    FBXProperty Export|IncludeGrp|Geometry|SmoothingGroups -v false;
    FBXProperty Export|IncludeGrp|Geometry|expHardEdges -v false;
    FBXProperty Export|IncludeGrp|Geometry|TangentsandBinormals -v false;
    FBXProperty Export|IncludeGrp|Geometry|SmoothMesh -v false;
    FBXProperty Export|IncludeGrp|Geometry|SelectionSet -v false;
    FBXProperty Export|IncludeGrp|Geometry|BlindData -v false;
    FBXProperty Export|IncludeGrp|Geometry|AnimationOnly -v false;
    FBXProperty Export|IncludeGrp|Geometry|Instances -v false;
    FBXProperty Export|IncludeGrp|Geometry|ContainerObjects -v false;
    FBXProperty Export|IncludeGrp|Geometry|Triangulate -v false;
    FBXProperty Export|AdvOptGrp|Fbx|AsciiFbx -v "Binary";
    FBXExport -f test $tbSaveLocation -s;

  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Spoke too soon, that hard codes the file directory as well as the name, I want the dialogue to remember the last export location and just use my provided name. Any help with that?
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Its probably easier to store the last export directory (either as a custom attribute on the mesh or in a variable. Depends how you want to handle different maya sessions) and then use that to generate the directory path. 

    EDIT: You can query it with $currentDir = `optionVar -q $gDirRetainingOptionVar`; That will get you the last export location.

    // Result: C:/Users/abraz/Desktop/DeleteMe // 

    Can reference C:\Program Files\Autodesk\Maya2015\scripts\others\setWorkingDirectory.mel.

    Might want to check it exists first before quering it 

    if (`optionVar -exists $gDirRetainingOptionVar`) {
    $currentDir = `optionVar -q $gDirRetainingOptionVar`;
    //Do Stuff
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Thanks I'll give that a try.
Sign In or Register to comment.