Export to FBX with relative paths for texture images


#1

Hi,

I’m trying to solve this puzzle for many years. How to export to fbx with maxscript and keep relative paths for texture maps?

I’m using this script I came up by the time:

(
	global pathStr = ""
	on expFbx pressed do
	(
		thePlugin = pluginManager
		thePlugin.loadClass FBXEXPORTER --loaded in memory and accessible

		FBXExporterSetParam "Animation" false
		FBXExporterSetParam "Cameras" false
		FBXExporterSetParam "Lights" false
		FBXExporterSetParam "SmoothingGroups" True
		FBXExporterSetParam "Preserveinstances" False
		FBXExporterSetParam "TangentSpaceExport" False
		FBXExporterSetParam "FileVersion" "FBX201300"
		FBXExporterSetParam "ASCII" false
		FBXExporterSetParam "UpAxis" "Y"
		FBXExporterSetParam "ConvertUnit" "cm"

		if maxfilepath == "" then maxfilepath_gb = "c:\\" --use "Untitled"
		else maxfilepath_gb = maxfilepath

		if maxFileName == "" then maxfilename_gb = "Untitled" --use "Untitled"
		else maxfilename_gb = getFileNameFile maxFileName --use the file name without .MAX extension

		theClasses = exporterPlugin.classes
		_objIdx = findItem theClasses FBXEXP
		sceneName = maxfilepath_gb + (getfileNameFile maxfilename_gb) + ".fbx"

		if selection.count != 0 then exportfile sceneName #noPrompt selectedOnly:on using:theClasses[_objIdx]
		else exportfile sceneName #noPrompt selectedOnly:off using:theClasses[_objIdx]
	)
)

However, this script saves only full paths, even tho I set up my paths as relative. I think it has something to do with the project folder, default folder or something like this.

One more thing, whenever I export my scene to FBX with a dialog (File -> Export) it saves my relative paths. From that point I can use my script to export to FBX and relative paths will be saved as well. That until I open another scene - I would need to export my new scene to FBX with dialog first in order my script to work for saving relative paths.

How to solve this?