Home Coding, Scripting, Shaders

FBX Export Maxscript Error "no "+" function for undefined"

Hi Guys,

I've just reopened a script i made a while ago, however I know it was working last time I used it, it's now not working.

When going through the export part of code it gives the error
no ""+"" function for undefined


The code is as follows:
fn ExportFBX filePath createFolder ObjName = (<br>	OpenFbxSetting()<br>	--File path and name <br>	if createFolder != false then (<br>		exportFolder = filePath + "\Export\\"<br>		if doesFileExist exportFolder == False do (makedir exportFolder)<br>	)<br>	else (<br>		exportFolder = filePath<br>	)<br>	exportPath = exportfolder + "\\" + ObjName + ".fbx"<br>	<br>	<br>	exportfile exportPath #noprompt selectedOnly:true using:FBXEXP<br>)
The error occurs on the following lines:
exportFolder = filePath + "\Export\\"
exportPath = exportfolder + "\\" + ObjName + ".fbx"
I determine the location chosen by the user in a previous function and pass it through as filePath, objName is also determined in the same function.
fn StartScript alignAxis zeroPosition exportType<br>	exportCheck folderCheck filePath = (<br>	SelectionCount = GetCurrentSelection()<br>	if SelectionCount.count > 1 then (<br>		messagebox "More than one object selected, please select only one object"<br>	)<br>	else (<br>		ObjectName = selection[1].name as string -- Get name of currently selected object<br>		if exportType != "OBJ" and exportCheck != false then ( --if user has picked FBX<br>			exportFBX filePath folderCheck ObjectName<br>		)<br>	)<br>)<br>


Any help is appreciated!


Replies

  • snowy1256
    Options
    Offline / Send Message
    I've managed to fix this kind of.

    My UI had a EditText box using getSavePath to determine it's .text value, for some reason the string variable given it's value by getSavePath was clearing itself between the user choosing the file location and hitting the export button in the UI.

    So now I just read the .text value and set that as filePaths value when the user hits export.

  • monster
    Options
    Offline / Send Message
    monster polycounter
    I'm glad you found a workaround. The original problem is a scope issue. The variable "exportFolder" exists inside the IF/ELSE statement, but not outside. So when you try to add it after the IF/ELSE there is nothing to add. It's a simple fix:

    fn ExportFBX filePath createFolder ObjName = (
    
    	exportFolder = filePath
    	OpenFbxSetting()
    
    	--File path and name 
    	if createFolder do
    	(
    		exportFolder += "\Export\\"
    		if not (doesFileExist exportFolder) do (makedir exportFolder)
    	)
    
    	exportPath = exportfolder + "\\" + ObjName + ".fbx"
    	exportfile exportPath #noprompt selectedOnly:true using:FBXEXP
    )

Sign In or Register to comment.