ScriptSpot

Forum topic · General Scripting

syntax help with maxSaveFile

By jdeehr · 2012-05-18

Description

This should be an easy one but I am stuck. I am concatenating some strings together to give a final file path, which I will later use in the saveMaxFile command. Here is the code.
finalFile = (finalRoot + "\\" + curAsset + ".max") as string

"finalFile" ends up being a valid string such as "C:\Users\jdeehr\Documents\sandBoxForAssetBrowser\models\few\jh\kj\kj.max" I even queried the type to be extra sure and sure enough, it is a string.

However, if I call the command saveMaxFile(finalFile) it says "cannot convert undefined to type:fileName." How is it that MAX thinks finalFile is undefined?

The other strange thing is if I hardcode in saveMaxFile("C:\Users\jdeehr\Documents\sandBoxForAssetBrowser\models\few\jh\kj\kj.max") It works.

How are finalFile (which obviously is going to vary) and hardcoding in a path such as "C:\Users\jdeehr\Documents\sandBoxForAssetBrowser\models\few\jh\kj\kj.max" different in the context of saveMaxFile()? Thanks.

Comments (7)

jdeehr · 2012-05-22

Thanks much.

Explanations for your question

barigazy · 2012-05-18

In maxscript help find the topic MAX File Loading and Saving. There you will find the best explanation.
At the buttom of topic page look for SEE ALSO topics.

kimarotta · 2012-05-18

Hi man, I tested a solution that can resolve to you

--- Defines base directory
finalRoot = "C:\Users\digital\Desktop"

--- Defines final file
finalFile = (finalRoot + "\\" + maxFileName) as string

saveMaxFile finalFile

or

--- Defines base name
baseName = "tst"

--- Defines base directory
finalRoot = "C:\Users\digital\Desktop"

--- Defines final file
finalFile = (finalRoot + "\\" + baseName + ".max" ) as string

saveMaxFile finalFile

jdeehr · 2012-05-18

Thanks. Can you also give an explanation why my method didnt work? I got the code to work with a dirty workaround but I would really like to understand why.

kimarotta · 2012-05-18

really is missing only the definition of variables, the code was correct. barigazy spoke as a look at help for a better understanding

barigazy · 2012-05-18

This concept also works

finalRoot = @"C:\temp\"
fileext = "test.max"
saveMaxFile (append finalRoot fileext)

update

jdeehr · 2012-05-18

I was able to do a workaround by putting finalFile into an array, and then iterating through that array and calling saveMaxFile for each item in the array. (In this case, only one item was in the array)

I still have no idea why this works though. Any insight would be great! Thanks.