Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

FBX export with maxscript to unity - roatated?

FBX export with maxscript to unity - roatated?

Anonymous
Not applicable
1,486 Views
5 Replies
Message 1 of 6

FBX export with maxscript to unity - roatated?

Anonymous
Not applicable

Hello

 

I want to export fbx through maxscript that should be imported into Unity.

When I am exporting manually with axis: y up it works perfectly.

when exporting with maxscript the model is sometimes rotated by 90 degrees, although I am setting fbx exporter parameter to y up in the code.

its like maxscript “lgnores” that parameter sometime.

 

Thanks in advance 🙂

0 Likes
1,487 Views
5 Replies
Replies (5)
Message 2 of 6

ads_royje
Alumni
Alumni

Hi @Anonymous ,

 

You may know and have looked at it before, just in case.

When exporting the fbx to ascii you can verify the up axis.

Open the .fbx and locate 

GlobalSettings:  {
	Version: 1000
	Properties70:  {
		P: "UpAxis", "int", "Integer", "",2

the value for UpAxis can either be 1 (Y-up) or 2 (Z-up).

 

When you export to fbx, do you specify the plugin to use ?

FbxExporterSetParam "ASCII" true
FbxExporterSetParam "UpAxis" #z
exportFile @"C:\*.fbx" #noprompt using:FBXEXP

Regards,

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hey

I am using the axis parameter (I need  y up), but I don’t need ascii.

0 Likes
Message 4 of 6

ads_royje
Alumni
Alumni

Hi,

 

when exporting as ascii, it can help to isolate if the issue is exporting the file or is in importing the file.

For instance, if the file has axis y up and it imports rotated, then the problem is on import. And vice-versa.

 

Do you specify the plugin to use ?

using:FBXEXP

 

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

I’m using the fbxexp, yes.

I believe it’s a problem with export because it’s working when exporting manually (not with maxscript)

0 Likes
Message 6 of 6

ads_royje
Alumni
Alumni

Hi @Anonymous ,

 

sorry for the delay in response.

 

Here is what I tried on my side, using Max 2020 update 1.
I've created a little script to create a bunch of Max files.

Of course, these are not production files, so it does not reflect exactly your environment.

Then the script loads and export as fbx all the max files. Fbx is exported Y up and as ascii to validate the up axis.

If the up axis is not as expected, the script prints out an error.
I've tried to batch export up to 2500 files with no variations on up-axis export, always the expected up axis.

Of course, this test is limited compared to using production files.
If you are open to the idea, if you could try to batch test your production files and see if you find if there are specific files that generate the problem.
You may try to add the read fbx file test with your exporting tool to see if it is possible to isolate the issue.

Sorry, I don't have much better 😕

Regards

-- working folder: set Root folder for script execution
-- execute script using: filein @"script path\scriptname.ms"
root_dir = (getFilenamePath (getSourceFileName()))

/*
create a bunch of max files inside a folder name scenefiles
using this to create max files for export test
if files already exists, no need to create these
*/
scenefilepath = root_dir + "\scenefiles\file_"
for i = 1 to 2500 do (
teapot()
saveMaxFile (scenefilepath + i as string + ".max")
resetmaxfile(#noprompt)
)

/*
laod and export files
*/

-- fbx file name to export, test export, read for Up Axis and report if not Y up
filename = root_dir + "\\test.fbx"
clearListener()

-- get all Max files in this location and recursive
-- this line expects root_dir to be defined and the folder scenefiles to exist
-- change the folder location for root of max production files to batch export and test for up axis
allmaxfiles = (getFiles (root_dir+"\scenefiles\*.max") recurse:true)

-- for all max files: export as fbx y-up and ascii, open fbx file ans seek for UpAxis line, find value and check if it matches the expected up axis. If not report error
for i = 1 to allmaxfiles.count do (
-- open max file
loadMaxFile allmaxfiles[i]

-- set export options and export
FbxExporterSetParam "ASCII" true
FbxExporterSetParam "UpAxis" #y
exportFile filename #noprompt using:FBXEXP

-- verify that file exists
if (doesFileExist filename) then (
    -- open fbx file for read
    readOpenfile = openFile filename

    -- read up to UpAxis
    skipToString readOpenfile "UpAxis"

    -- read the full line
    thisline = readLine readOpenfile

    -- print it for record
    print thisline

    -- validate the Up Axis value, if not 1 (Y up) then error
    if thisline[thisline.count] != "1" then (format "Error: Not expected Up Axis in file:\n\t%\n" allmaxfiles[i])

    -- close fbx file
    close readOpenfile

    -- delecte fbx file
    deleteFile filename
    ) else (format "File % does not exists" filename)
)
0 Likes