syntax help with maxSaveFile

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jdeehr's picture

Thanks much.

Thanks much.

barigazy's picture

Explanations for your question

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.

barigazy

kimarotta's picture

hi

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

kimarotta.com.br
3d Artist  

jdeehr's picture

Thanks. Can you also give an

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's picture

really is missing only the

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

kimarotta.com.br
3d Artist  

barigazy's picture

This concept also works

This concept also works

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

barigazy

jdeehr's picture

update

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.