Free Support Forum - aspose.com

Exception "Index was outside the bounds of the array" while converting FBX file to GLTF using Aspose.3D for .NET

TEST.zip (194.2 KB)

When I open the attached FBX file, and attempt to save it as a GLTF (in any of the 4 supported GLTF formats), using the code below:

Scene scene = new Scene();
scene.Open("TEST.fbx");
scene.Save("Test.gltf", FileFormat.GLTF);

I get the following exception:

An unhandled exception of type ‘Aspose.ThreeD.ExportException’ occurred in Aspose.3D.dll: ‘Index was outside the bounds of the array.’

This happens for a variety of other FBX files in my application.

@OBCad,

I have worked with source files and sample code shared by you using Aspose.3d latest version on my end and unable to observe the issue.Can you please try to use latest version on your end.Test.zip (18.9 KB)

Aspose3dTest.zip (2.1 MB)
I updated to the latest version of .net core and aspose. Attached is my complete project directory in a zip (except my license file.)

Here is the main method body:

Console.WriteLine("Setting license");
		Aspose.ThreeD.License license = new Aspose.ThreeD.License();
		license.SetLicense("Aspose.3D.lic");

		System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(Aspose.ThreeD.Scene));
		Console.WriteLine("Aspose.3d Version: " + asm.FullName);

		asm = System.Reflection.Assembly.GetAssembly(typeof(System.Int32));
		Console.WriteLine(".Net Core Version: " + asm.FullName);

		Scene scene = new Scene();
		scene.Open("TEST.fbx");
		Console.Write("Trying to export to GLTF... ");
		try
		{
			scene.Save("Test.gltf", FileFormat.GLTF);
			Console.WriteLine("Success!");
		}
		catch (System.Exception ex)
		{
			Console.WriteLine("EXCEPTION: " + ex.Message);
		}

The output is:

Setting license
Aspose.3d Version: Aspose.3D, Version=20.1.0.0, Culture=neutral, PublicKeyToken=f071c641d0b4582b
.Net Core Version: System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
Trying to export to GLTF... EXCEPTION: Index was outside the bounds of the array.

What might I be missing?

@OBCad,

Can you please share complete environment details with us.

EvironmentReport.zip (202.4 KB)
Attached is my windows MSINFO report for my env.

I also tried running the same project on a MacOS machine and get the same exception result, if that helps.

Aspose3dTest-Docker.zip (179.9 KB)

Here is the project in a Microsoft docker image, which reproduces the error. Just open it up and run a docker build .

@OBCad,

Thank you for the details.

We have logged a ticket with ID THREEDNET-632 in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

I see the ticket has been resolved; what was the result? Is there a patch or new release?

@OBCad,

Can you please use following code to manually fix the transparency and convert the scene. Also please note, if there’s nothing in the converted file, it’s caused by the transparency of material, material in FBX file has two properties to define the transparency, which may cause conflicts in some applications.

Scene scene = new Scene();
scene.Open(@“TEST.fbx”);
scene.RootNode.Accept((node) =>
{
if (node.Material is PhongMaterial)
{
((PhongMaterial)node.Material).Transparency = 0;
}
return true;
});
scene.Save(@“TEST.glb”, new GLTFSaveOptions(FileContentType.Binary) { EmbedAssets = true });