Version 2.4
This script was created for the purpose of taking some of the tedium out of exporting assets regularly to the Unreal Editor, and has been used in full production with Unreal Engine 4 & 5. The main idea behind the script is to speed up exporting of static meshes, skeletal meshes, single skeletal animations and batches of separate skeletal animation files.
The script will attempt to do most of the work for you, by identifying relevant objects within a Max scene without you needing to unhide, unfreeze, or rely on selection sets or scene layers. You can however specify through selection which assets the script should use to export from, to override its default automatic behavior. Used correctly, it will speed up the export process greatly so you can focus on iterating.
It is a fairly generic script for exporting and doesn’t support features such as source control (like Perforce), or project specific workflows. However, once you understand how the script works with scene objects and selection your export workflow will improve.
Key Features:
Define an export path using a variety of methods, or simply export to the currently open scene folder.
Export static meshes and their collisions (supports Box “UBX_”, Convex “UCX_”, Capsule "UCP_", and Spherical “USP_” volume types). Note: It does not actually create the collisions.
Export skeletal meshes and their bind skeleton (game rig).
Export a single skeletal animation (scene) or batch export from a folder of animations.
Static mesh exports output to a text log file, showing all collisions found and any potential collision name errors.
Skeletal mesh and animation exports report a summary to the Maxscript Listener.
Exporting is non-destructive to the original source – i.e. the original file is not saved if changes are made to the scene for export purposes.
Blendshapes from the Morpher modifier can be exported.
Level of Detail (LoD) utility sets are supported for both static meshes (including their collisions) and skeletal meshes.
Supports up to FBX version 2023 (as of version 2.4).
Additional Features:
Specify an export path using a dropdown list of paths stored in a text file. You can specify a root path for the text file dropdown list paths to shorten the full path length.
Specify a limited set of exposed FBX export options via a Settings dialog.
Quickly export using Shift+Click on the menu item or toolbar without opening the interface.
Specify whether static meshes are origin centered, world oriented or pivot centered.
Export static meshes to a single FBX file for convenient storage. Defaults to separate files for each static mesh found.
Export separate meshes as a single attached mesh.
Use selection sets to determine what static meshes to export.
Grouping and linking are supported for static meshes and their collisions.
Export skeletal meshes with either full or partial hierarchy selection.
Export separate skeletal meshes (with a shared rig) as a single export file using a Gestalt method.
Skeletal meshes can be grouped (for convenience) even if not part of a Level of Detail set.
Specify using named selection sets any skeletal meshes that share a skeleton with the Gestalt method. This option allows for multiple hierarchies in the same scene.
Specify what skeletal mesh is used by adding a skin mesh name (both scene and batch exporting are supported).
Specify an animation name for output to override using the Max file name.
Use time tags to export a combined animation made up of multiple sequences as separate sequences based on the tag name and range specified.
Batch export skeletal animation from a selection of Max files chosen from a list and sorted by either name or date. You can recurse all subfolders. Also supports time tags.
Limitations:
Does not do anything with materials.
Does not support source control (e.g. Perforce).
Does not interact at all with Unreal, it only exports content from 3ds Max.
Does not support skeletal animation exporting using multiple takes in one FBX file.
Once the script has been installed it will be available as a toolbar icon or you can assign a hotkey to it. You'll find it in the LB Tools category in the Customize menu.
Clicking the gear icon will open another dialog containing various settings.
The Root Path field is used to define the start of a path segment that represents your export path (see the Path Settings section below). Typically this is the root path of your main art source folder. The purpose of this path is to reduce the overall width of the saved paths dropdown list, so they only display the subfolder path strings. The C button is used to check if the entered path is valid.
Below that are some exposed FBX Export Settings you can override, as most of the settings are predefined. The script will override any settings from previous manual exports done through the file export FBX interface.
Skeletal meshes can support the use of the Level of Detail utility plugin in Max which FBX and Unreal will recognize. The Remove Level of Detail (LoD) on selection will allow you to explode any LoD sets to disassociate the plugin for selected LoD groups.
Title decal theme toggle will change the main title to either a dark or light variant.
Export Path is where the exported files will go by default and it is up to you to define where this will be. You can enter the path manually by typing or pasting it in, browse to it using the [...] button, or use the TXT button to open a text file and add the full sub-paths to that. The x button will clear the edit field.
Alternatively, you can override the export path by using the Same folder as scene file checkbox.
If using the text file method, you'll need to provide the full path on a separate line for each subfolder. For example...
D:\Art_Source\Characters\Enemy_Flying
D:\Art_Source\Characters\Enemy_Grunt
D:\Art_Source\Characters\Enemy_Quadraped
D:\Art_Source\Characters\Hero_Male
D:\Art_Source\Characters\Hero_Female
Note that there is no backslash at the end!
The paths will then display in the dropdown list and selecting one will place it in the Export Path edit field. The R button is used to refresh the list if the text file has changed.
In the Settings dialog (as explained above) the provided Root Path will remove the start of each subfolder path string for each item in the list, in order to make the overall list width shorter.
The folder icon is used to open an Explorer window to browse to the current export path.
Note that export folders are not created for you, so you must provide already valid paths.
To export, simply press the relevant button either STATIC or SKELETAL. The file(s) will be output according to either the Export Path or the Same folder as scene file (if that option is checked).
Alternatively, you can use Shift + Left Click on the toolbar icon when the interface is closed to execute a quick export. This option uses the last saved settings from the interface which can improve your iteration time.
Choose which method will respond to the quick execution at the bottom of the UI.
Note:
Batch animation exporting is not available using the quick execution method.
Some of the functionality is contextual to the interface options or whether you have objects selected. Understanding this behavior is important to using the script successfully.
If any of the export files are marked as read only, they will be made writable and overwritten without prompting. A summary will be presented at the end of exporting telling you if new files were added, existing files overwritten or overwritten files which also need to be reconciled (i.e. they were marked as checked in by Perforce for example).
Example summary: In this case the Box.fbx has been overwritten, but requires reconciliation (checking out) in Perforce, or made writable because it was not checked out for editing first.
The maxscript listener will output a summary log of what was exported for both static and skeletal methods.
Additionally, the static export method will output the same log to a text file. This can be useful for determining if valid collisions were found.
In the static mesh options section you can toggle Display Log File to show the log summary text file after exporting. The button Open Log File will also open the same log summary file.
In the example log below, the UCP_Capsule001_invalid collision object does not match the static mesh name Capsule.
LB Tools - Export FBX to Unreal - Static Meshes - 11/09/2022 1:32:45 PM
Scene file... C:\Users\Documents\3ds Max 2023\scenes\FBX_static_export.max
Exported as separate FBX files using the static mesh names.
Export Path... D:\Art_Source\Static_Meshes\
-------------------------------------------------------------------------------------
### STATIC MESH...
Sphere
### VALID COLLISIONS FOUND...
USP_Sphere
!!! POTENTIALLY INVALID COLLISIONS...
-------------------------------------------------------------------------------------
### STATIC MESH...
Box
### VALID COLLISIONS FOUND...
UBX_Box
!!! POTENTIALLY INVALID COLLISIONS...
-------------------------------------------------------------------------------------
### STATIC MESH...
Convex
### VALID COLLISIONS FOUND...
UCX_Convex
!!! POTENTIALLY INVALID COLLISIONS...
-------------------------------------------------------------------------------------
### STATIC MESH...
Capsule
### VALID COLLISIONS FOUND...
!!! POTENTIALLY INVALID COLLISIONS...
UCP_Capsule001_invalid
For more information on static mesh collisions, see the official Unreal documentation here .
These options affect either the STATIC (left) or SKELETAL (right) export buttons.
When exporting using the Static option, you can either select what you want to export or just let the script find any valid geometry. The script will attempt to locate and select any validly named collision volumes associated with each static mesh or Level of Detail set. It will report the output results to a log file for your analysis.
Single Mesh – Creates duplicates of the current selection, attaches them into a single mesh, exports the single mesh to a single FBX file based on the Max file name then deletes the new mesh leaving your original scene intact.
Centre At Origin – This will reposition static meshes to the origin and either align their pivots to the center of the mesh or leave the pivots as is. This is dependent on the sub-options for either Orient World or Centre Pivot. Especially useful if you have scenes setup so that objects are offset from the origin – for ease of viewing. Also affects the Single Mesh option. Note: This option also moves any associated collision volumes by first linking them to their static meshes. There’s no need to manually link them prior to exporting.
Output to a single FBX file – If checked, all static meshes and collisions found will be saved into a single FBX file. The output name will be the Max file name with the added prefix StaticMeshes_. For example: Building_A.max = StaticMeshes_Building_A.FBX.
Selection Set – Uses collections of static meshes created with selection sets accessible via a drop-down list. A chosen selection set will be used to select the static meshes to export as though selecting them manually. This allows meshes to be isolated from other scene geometry, frozen or hidden without requiring manual selection. This option overrides the default behavior of using either manual selection or exporting all the scene geometry as static meshes.
- The r button will refresh the list in case the scene data has changed.
- The x button will delete all scene selection sets and clear the list.
Display Log File – Displays a text file after exporting static meshes. It is stored in C:\Temp\LBTools_ExportLog.txt and contains information on what static meshes were exported and their associated collision volumes. There’s an Open Log File button which will open this text file for quick editing. This excludes Single Mesh exports.
Full Rig or Partial Rig – When exporting skeletal meshes, the output will usually be a single FBX with the skin mesh name as the saved filename. The scene must have a valid skin mesh (using the Skin modifier) containing assigned bones. Depending on user scene selection, it will determine the appropriate skin mesh and skeletal hierarchy to export. If nothing is selected, it will search the scene for valid skin meshes and operate on those.
The script also handles exporting multiple skinned meshes at once and will output these as separate files using the skin mesh name for each as the filenames. The mode chosen (Full Rig or Partial Rig) will determine whether to include the entire hierarchy of bones or use only the skin bones found in the skin mesh.
Note: Partial Rig exporting will always include the parent bones up to the root, even if exported manually without this script.
Gestalt – Allows exporting of separately skinned meshes that share a hierarchy as a single skeletal mesh. You can have multiple hierarchies in the scene in this case.
Three methods for export using the gestalt option include:
Selection Sets; Finds all user defined selection sets tagged using the prefix FBX_ followed by the output name for collections of skinned meshes that share the same hierarchy. Nothing should be selected initially for this option to work.
Nothing selected; Finds all hierarchies and exports a single FBX file containing a single skeletal mesh for each hierarchy which in turn are made up of separately skinned meshes. Uses the name of the Max file as output.
Selected objects; Finds any skinned meshes in the selection and if they share the same hierarchy, exports them as one mesh. Uses the name of the Max file as output.
Animation – Exports bone animations using the name of the Max file as the output for the FBX animation file. There’s an edit field provided to allow the animator to specify a valid Skin mesh name to export from should there be more than one skin mesh in the scene. This saves the animator from needing to select a skin mesh in case there are multiple skinned meshes skinned to different rigs. For example; choosing either a weapon rig or a character body rig. If no skin mesh name is provided and nothing is selected when exporting a multi-hierarchy scene, a dialog will appear prompting you to select a skin mesh name to use along with a continue process button.
You can also specify an Output name to override the Max file name default behavior. This can be useful in cases where you have multiple animations in one scene (like cinematic work) and you don’t want to use the Max file name as the sequence. The x buttons clear the edit fields and focus on them for quick editing.
Animation: using scene Time Tags – Correctly formatted time tags are supported for animation exporting of composite sequences. For example, you may have a single Max file which contains animation for a start, loop and end sequence on different time frames. You can have any number of sequences and their times can even overlap. This process can make animation editing easier as you only need to edit one Max file.
The Animation mode will automatically look for any time tags and export each sequence using the tag name and the range specified within the tag. The Ignore time tags option can be used with both Animation mode and Batch Animation – it simply exports a single FBX file using the Max file name, irrespective of any existing time tags, in case tags were used for time navigation instead.
The time tags must conform to a specific format to be recognized for this purpose.
The format should be in the form… tagName[space]startTime[dash]endTime
(e.g. Jump_Start 0-50)
When setting up time tags:
- No spaces should be in the name, use underscores instead.
- Only one space should exist between the name and the start time.
- Use a dash to separate the start and end times.
- Time ranges can overlap and don’t need to relate to one another.
Another feature using time tags is the ability to only export a specific sequence by selecting a tag name in a dropdown list (below the skin mesh name field). There’s a checkbox next to the list to activate this feature. If unchecked, all time tag sequences will be exported. The r button will refresh the list in case the scene data has changed. The UI will also populate the list when first opened, if any tags are found. The x button deletes any existing scene time tags.
Note: The time tag settings don’t get stored in the interface INI file when changed. However, you can invoke these to export a single sequence using the Shift + Left Click method to execute an export, but if you restart the interface the settings will be reset.
Batch animation export button...
This section allows you to be able to quickly export from a folder of "export ready" skeletal animation Max files. It assumes the export rig that the mesh is skinned to is in the scene and the skin is valid (has bones assigned).
An edit field is available to specify a Skin mesh name if there are multiple skinned meshes in the scene. Only the specified mesh (if valid) will have its animation exported. Leave it blank if you know there is only one skinned mesh in the animation files.
Note: This process is not as comprehensive at selecting a valid skin mesh when compared to exporting a single animation file using the Skeletal button. It will simply attempt to find the first skin mesh to export from. If multiple skin meshes on different rigs are in the scene you should specify a skin mesh name to reference the export rig from.
You can also enable a Selected maxfiles option so that when the batch export process is run a new dialog will be shown that lists all the Max files in the chosen Source Path. Simply select one or more file names from the list then hit the export button below it. If this option is off all Max files found in the chosen source path will be exported and the dialog won’t appear.
The list can be sorted by either name or last date modified. There is also a browse button […] for reassigning the source path. File output will either be to the specified Export Path or the current scene folder if the Same folder as scene file option is checked in the main UI.
No recursive subfolders
If the Recurse subfolders option is also checked, the script will traverse any subfolders within the chosen source path and export all Max files found. It will automatically create new subfolders in the Export Path to match the same subfolder structure as the source path.
If the selected Max files option is also used, the dialog displays the subfolders as a prefix next to the Max file names, unless they are in the root of source path. The recurse subfolders option can be toggled while the selected Max files dialog is displayed and will update the list.
A LoD is a special group of objects created using the Level of Detail utility plugin in 3ds Max.
The user first defines a group of LOD objects of varying mesh densities, then creates a set using the LoD utility with defined distances.
Unreal supports the auto-importing of LOD’s into both static meshes and skeletal meshes if exported as part of a single FBX. This script will support both of these cases.
In order to properly export static mesh LoD groups along with their collisions using the script, please be aware of the following…
Collision volumes should be named according to the LOD names within the group, not the group name. Otherwise, normal naming conventions apply as per non-LoD static meshes. Unreal will not recognize collision meshes if they are not named correctly.
See the official Unreal documentation here for collision naming.
If there is more than one LoD object in the scene that has collision meshes, those collision meshes must be linked to their associated LoD. This is so that the script can identify which collision meshes belong to which LoD mesh, in case their LOD’s share the same names as other LoD set meshes.
A single LoD with collisions in the scene does not need to have its collisions linked.
Note that having anything linked to the LoD that is not part of the set will cause Max to crash. However, as stated above for multiple LoD’s in the scene the script will handle this, but only for valid collisions.
For more information on setting up LOD's using the LoD utility plugin in 3ds Max for Unreal go here.