New FBX Exporter in 2017.2

Maya 2013 doesn’t appear to work.

Awesome thx guys!! 3Ds Max integration close?

I’ve got a 3D model in unity. It consists of several 3D buildings, trees, and streets. I would like to export all the objects (buildings, trees, and streets) as FBX. In order to do so I use “FBX Exporter (beta)”. Some of the objects can be easily exported, but some of them not.
I get the following error when try to export some of the objects:

IndexOutOfRangeException: Array index is out of range.
FbxExporters.Editor.ModelExporter.ExportComponentAttributes (FbxExporters.Editor.MeshInfo mesh, Unity.FbxSdk.FbxMesh fbxMesh, System.Int32[ ] unmergedTriangles)
FbxExporters.Editor.ModelExporter.ExportMesh (FbxExporters.Editor.MeshInfo meshInfo, Unity.FbxSdk.FbxNode fbxNode)
FbxExporters.Editor.ModelExporter.ExportMesh (UnityEngine.GameObject gameObject, Unity.FbxSdk.FbxNode fbxNode)
FbxExporters.Editor.ModelExporter.ExportComponents (UnityEngine.GameObject unityGo, Unity.FbxSdk.FbxScene fbxScene, Unity.FbxSdk.FbxNode fbxNodeParent, Int32 exportProgress, Int32 objectCount, Vector3 newCenter, TransformExportType exportType)
FbxExporters.Editor.ModelExporter.ExportComponents (UnityEngine.GameObject unityGo, Unity.FbxSdk.FbxScene fbxScene, Unity.FbxSdk.FbxNode fbxNodeParent, Int32 exportProgress, Int32 objectCount, Vector3 newCenter, TransformExportType exportType)
FbxExporters.Editor.ModelExporter.ExportComponents (UnityEngine.GameObject unityGo, Unity.FbxSdk.FbxScene fbxScene, Unity.FbxSdk.FbxNode fbxNodeParent, Int32 exportProgress, Int32 objectCount, Vector3 newCenter, TransformExportType exportType)
FbxExporters.Editor.ModelExporter.ExportAll (IEnumerable`1 unityExportSet)
FbxExporters.Editor.ModelExporter.ExportObjects (System.String filePath, UnityEngine.Object[ ] objects)
FbxExporters.Editor.ModelExporter.OnExport ()
FbxExporters.Editor.ModelExporter.OnContextItem (UnityEditor.MenuCommand command)
UnityEditor.GenericMenu:CatchMenu(Object, String[ ], Int32)

Somebody told that “it seems one of the objects you are trying to import to FBX has a script in which you may have an array that is null or is getting out of range. I will advise checking the objects you have a script attached to see if that is the case.” I removed all the scripts from the model. But still does not work.

Do you have any idea?

Regards,

Hey, we are a team (DADIU) having problems with linked prefab instances. Specifically we want to have model updates AND texture updates be reflected in Unity after they are updated in Maya. Model updates, and the material itself is updated, but textures are never embedded when using this plugin.

The showcase video highlights using a Stingray PBS shader, but from I gather from the documentation, a lambert material with a texture should work aswell. I cannot seem to get it to work. Have anyone gotten it to work yet, and would like to share their knowledge?

Hi Tinovdk,

Thank you, I’ve downloaded the file and logged the issue. We will check it out and get back to you.

Best,
Viktoria

Hi @laurentlavigne ,

The plugin supports Maya 2017 or later. We still allow the option to try installing to earlier versions of Maya, however, it is not guaranteed that they will work.

Best,
Viktoria

Hi @Shodan0101

Yes we will release a new version of the package soon which will include the integration for 3Ds Max 2017 or later. We would love to get your feedback once it’s out :slight_smile:

Best,
Viktoria

1 Like

Hi unity_ikjJtsxUu_cS4A,

Could you please share a package containing a prefab for one of the objects that you are unable to export?

An easy way to create the package is to create a prefab for your object if you haven’t already, then right click on the prefab in the project view and select “Export Package…”. This should export the prefab and any dependencies to a .unitypackage.

Best,
Viktoria

AWESOME!! :smile: Will do! Thx guys!

1 Like

Hi @TheFragen ,

In order for Unity to find textures added in Maya the textures will have to either be placed in the Unity project or embedded into the FBX file.

For more information on where Unity searches for textures you can check out these links:
http://answers.unity3d.com/questions/47733/importing-from-maya-textures-gone.html
https://docs.unity3d.com/Manual/class-Mesh.html

If you would like to export textures as embedded from Maya using the Maya Unity plugin, it’s possible to change the export settings by modifying the following file in the FBX exporter package: “FbxExporters/Integrations/Autodesk/maya/scripts/unityFbxExportSettings.mel”
In the file you should see a line that says

FBXExportEmbeddedTextures -v false;

if you change the “false” to “true” then textures will be embedded on export.

Let me know if this doesn’t fix the problem or if you have any other issues.

Yes you’re right, lambert material with a texture should work as well.

Best,
Viktoria

Great thank you, that did indeed solve the issue. Very much appreciated.
I want to add, that when we export models with animations, we have to bake them manually first. Baking is done automatically when exporting to fbx through File → Export. Further, when the model is imported in Unity, we have to find the model in Project, go to Rig, and set Animation Type to Generic to get animations, rather than it being set automatically.

My pleasure, glad it solved the issue.

For exporting animations from Maya, you can again modify the “FbxExporters/Integrations/Autodesk/maya/scripts/unityFbxExportSettings.mel” file in the FBX exporter package.
Adding these lines to the file will let you set the same bake animation options as in File->Export:

// Set to true to bake animation on export
FBXExportBakeComplexAnimation -v true;
// set the start time for baking the animation
FBXExportBakeComplexStart -v [int];
// set the end time for baking the animation
FBXExportBakeComplexEnd -v [int];
// set how many keys are created per frame
FBXExportBakeComplexStep -v [int];
// turn resample all on or off
FBXExportBakeResampleAll -v false;

You can replace [int] with the appropriate start, end, and step values.

Alternatively, you can comment out or remove the first line of the unityFbxExportSettings.mel file which is:

FBXResetExport;

This will make it so that the File->Unity->Export button uses the same settings as the File->Export for everything that is not explicitly set in the unityFbxExportSettings.mel file.

I’m assuming you are exporting an inanimate object such as a spaceship with animation, correct?
Are you seeing this when exporting the model from Unity as well (i.e. if you check the model import settings immediately after you export or convert to linked prefab instance)?

I’m trying to recreate the issue and so far I have done the following:

  1. Create Cube in Unity scene
  2. Convert Cube to linked prefab instance
  3. Check created fbx import settings → Animation Type is set to none
  4. Import into Maya
  5. Export from Maya with animation
  6. Check fbx in Unity → Animation Type is still set to none

It looks like the issue is related to the fact that we currently don’t support export of animations from Unity, however we will have to investigate further to know for sure.

Hey vkovec, apologies for the late reply. Your suggest to add bake animation options to unityFbxExportSettings.mel successfully exports models with animations.

You are right that it is inanimate objects (without a rig) we try to export. I can recreate your step-by-step guide, but as I said, animations are fully imported, once we set Animation Type to Generic. This option sticks for all future re-imports. It’s fine we have to change the setting, I just wanted to make you aware of it.

For anyone Googling this in the future, here are the export settings we ended up using for exporting animations:

// Animations
FBXExportBakeComplexAnimation -v true;
FBXExportBakeComplexStart -v 0;
FBXExportBakeComplexEnd -v `playbackOptions -query -animationEndTime`;
FBXExportBakeComplexStep -v 1;

please! make it runtime! and importer too!

2 Likes

runtime importer… that’s my dream come true. haha

1 Like

I got the same problem, here is the stack trace. Also, it is working fine with OSX + Maya 2018, but errors with Windows 10 + Maya 2018

select -r Cube ;
exportCmd.(‘init’,) [()]
exportCmd.(‘del’,) [()]

Error: object of type ‘int’ has no len()

# Traceback (most recent call last):

# File “C:\Users\Peter\Documents\project\Assets\FbxExporters\Integrations\Autodesk\maya\scripts\UnityFbxForMaya\commands.py”, line 276, in doIt

# if not self.loadUnityFbxExportSettings():

# File “C:\Users\Peter\Documents\project\Assets\FbxExporters\Integrations\Autodesk\maya\scripts\UnityFbxForMaya\commands.py”, line 83, in loadUnityFbxExportSettings

# fileName = os.path.join(projectPath,“Assets”, maya.cmds.optionVar(q=“UnityFbxExportSettings”))

# File “C:\Program Files\Autodesk\Maya2018\bin\python27.zip\ntpath.py”, line 67, in join

# p_drive, p_path = splitdrive(p)

# File “C:\Program Files\Autodesk\Maya2018\bin\python27.zip\ntpath.py”, line 115, in splitdrive

# if len(p) > 1:

# TypeError: object of type ‘int’ has no len()

Traceback (most recent call last):

File “”, line 1, in

File “”, line 2, in unityExport

RuntimeError: object of type ‘int’ has no len()

# Traceback (most recent call last):

# File “C:\Users\Peter\Documents\project\Assets\FbxExporters\Integrations\Autodesk\maya\scripts\UnityFbxForMaya\commands.py”, line 276, in doIt

# if not self.loadUnityFbxExportSettings():

# File “C:\Users\Peter\Documents\project\Assets\FbxExporters\Integrations\Autodesk\maya\scripts\UnityFbxForMaya\commands.py”, line 83, in loadUnityFbxExportSettings

# fileName = os.path.join(projectPath,“Assets”, maya.cmds.optionVar(q=“UnityFbxExportSettings”))

# File “C:\Program Files\Autodesk\Maya2018\bin\python27.zip\ntpath.py”, line 67, in join

# p_drive, p_path = splitdrive(p)

# File “C:\Program Files\Autodesk\Maya2018\bin\python27.zip\ntpath.py”, line 115, in splitdrive

# if len(p) > 1:

# TypeError: object of type ‘int’ has no len()

I got the same issue and ran the script, here’s what I got:

UnityAsset <type ‘unicode’> C:/Users/Peter/Documents/project/Assets/Export_From_Unity/Assets
UnityExportFileType <type ‘unicode’> FBX export
UnityProject <type ‘unicode’> C:/Users/Peter/Documents/project

When I ran it on OSX I got:

UnityApp <type ‘unicode’> /Applications/Unity2017_2/Unity.app
UnityAsset <type ‘unicode’> /Users/ben/project/Assets/PrototypeScene_01/Models
UnityExportFileType <type ‘unicode’> FBX export
UnityFbxExportSettings <type ‘unicode’> FbxExporters/Integrations/Autodesk/maya/scripts/unityFbxExportSettings.mel
UnityFbxForMaya_Headless <type ‘unicode’> 0
UnityInstructionPath <type ‘unicode’> _safe_to_delete/_temp.txt
UnityProject <type ‘unicode’> /Users/ben/project
UnityTempSavePath <type ‘unicode’> _safe_to_delete

I just ran the installation again and it now works fine. I can’t be sure, but maybe the wrong Maya version was selected in the first installation.

Hi @TheFragen great I’m glad animation is exporting now :slight_smile:

This was an interesting find, I’ve logged it as an issue. Thanks for letting us know!

Hi @mrbenn , thank you for sending the stack trace and variable values. It looks like the configuration did not set all the necessary variables on Windows. Particularly, the problem you are seeing is due to the “UnityFbxExportSettings” optionVar not being set.

I’m glad it ended up working. I just tried installing to Maya 2017 then opening Maya 2018 and it does in fact cause this problem if I try to use the plugin in Maya 2018. Another possible cause could be resetting the Maya preferences after installing the Unity integration.

Best,
Viktoria