Home Coding, Scripting, Shaders

3dMax 2016. One click export

polycounter lvl 6
Offline / Send Message
AlexandrL polycounter lvl 6
Hi guys :)

I need some really basic "one click export" which can be binded to some short-key or button. 
Currently i have frustrating routine like File->Export->... and so on.
I dont need any changes in pivot, reset x-form and collapsing stack. Only regular export to FBX like i do ot currently, but just by one click.

Unfortunately i'm completely experience less person in terms of maxscripts. But i believe its some pretty damn simple script?

I Found this thread: https://polycount.com/discussion/132959/3ds-max-how-to-export-a-fbx-file-without-pop-up-windows
But my naive trials to modify the code wasnt success =/

Replies

  • Mark Dygert
    if $ != undefined then (
    	curObjectName = $.name
    	exportpath = maxFilePath + CurObjectName
    
    	pluginManager.loadClass FBXEXPORTER
    	FBXExporterSetParam "SmoothingGroups" true
    	FBXExporterSetParam "SmoothMeshExport" false
    	FBXExporterSetParam "Triangulate" false
    	FBXExporterSetParam "Animation" false
    	FBXExporterSetParam "Lights" false
    	FBXExporterSetParam "ASCII" true
    
    	exportFile exportpath #noPrompt selectedonly:true
    )
    else (
    	messagebox "Nothing selected..." title: "Nope"
    )
    
    
    Yea you don't need much to just export from a button.

    Highlight and drag that code into your toolbar to make a button and when you click it, it will export a fbx file with the above settings. If you don't care about the settings you can drop that middle section and it will use whatever settings you used last time. 

    It exports to the path of the currently open max file and uses the objects name, for the name of the fbx file.

    If you don't have anything selected, it complains.

    I hope that helps!
     
  • AlexandrL
    Offline / Send Message
    AlexandrL polycounter lvl 6
    if $ != undefined then (
    	curObjectName = $.name
    	exportpath = maxFilePath + CurObjectName
    
    	pluginManager.loadClass FBXEXPORTER
    	FBXExporterSetParam "SmoothingGroups" true
    	FBXExporterSetParam "SmoothMeshExport" false
    	FBXExporterSetParam "Triangulate" false
    	FBXExporterSetParam "Animation" false
    	FBXExporterSetParam "Lights" false
    	FBXExporterSetParam "ASCII" true
    
    	exportFile exportpath #noPrompt selectedonly:true
    )
    else (
    	messagebox "Nothing selected..." title: "Nope"
    )
    
    
    Yea you don't need much to just export from a button.

    Highlight and drag that code into your toolbar to make a button and when you click it, it will export a fbx file with the above settings. If you don't care about the settings you can drop that middle section and it will use whatever settings you used last time. 

    It exports to the path of the currently open max file and uses the objects name, for the name of the fbx file.

    If you don't have anything selected, it complains.

    I hope that helps!
     
    Hi, Mark. Yeah its pretty close to magic button what i need ) Thanks!

    I read a little about max script and try to change script to the way:
    export file with current .max file name.
    Like, if i have blah_blah.max, exported file should have the same name - blah_blah.fbx

    I was try using maxFileName, cause it looks like correct command for that sort of things, but with no luck :(

  • Noors
    Offline / Send Message
    Noors greentooth
    getFilenameFile maxfilename<span>CurObjectName = </span>


  • AlexandrL
    Offline / Send Message
    AlexandrL polycounter lvl 6
    Noors said:
    getFilenameFile maxfilenameCurObjectName = 


    Get file name file... jeezz :) That repeated "file" really looks like a typo at first glance! But yeah it works like a charm! 
    Thanks, Noors :)

  • Mark Dygert
    Nice one guys! Yea I wasn't sure how you wanted to name it so I went with the object. 

    Maxfilename returns the file name with the extension so your fbx file would be .../mything.max.fbx
    If you use the getfilenamefile on the maxfilename it drops the extension and just returns the name of the file.

    If you're looking to expand on your script later, you can check out one I made a few years back. At the time I had it autoload on startup and it docked itself in the toolbar. It was nice having a compact one button solution. It has some features you probably won't need like,
    • Renaming the material.
    • Triangulating the mesh.
    • Setting and storing the path.
    • Move the object to world 0 0 0 and then move it back
    • Export the currently selected object or if nothing is selected go through each object and export them one at a time.
    So there is some fluff you can trim out. But feel free to dig through and use whatever is useful.


    https://polycount.com/discussion/93587/fbxport-a-maxscript-to-help-automate-exporting-files-to-udk/p1?new=1


    If you get into modifying it and have questions hit me up =)
  • Pac_187
    Offline / Send Message
    Pac_187 polycounter lvl 11
    Since you are modifying the FBX Export/Import settings via maxscript this will also have an effect on the settings that apply when you do a File -> Export... or File -> Import...

    If you don't want to mess with the users current settings while still applying specific settings in your script, do it like this:

    FBXExporterSetParam "PushSettings" -- this will save the current FBX settings
    -- now you can apply other FBX settings
    -- FBXExporterSetParam ...

    -- wrap the export into a try/catch so we always have a chance to rollback the FBX settings
    try
    (
    -- other code + export code
    )
    catch
    (
    -- throw an error message if something went wrong
    )

    FBXExporterSetParam "PopSettings" -- this will restore the previously saved settings

    -- the same template applies to importing, just use FBXImporterSetParam ...



Sign In or Register to comment.