save max file as maxversion 2010

hi
i was wondering how i can make a button that saves a max file as a previous version
i found the help but could not get the code to work

max file save [SaveAsVersion:2010]

or saveMaxFile etc. tried lots of things but never worked

what should i do?

thanks

Comments

Comment viewing options

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

Hey Ian

maybe something like this...

-- get the base file name w/o the extention ".max"
maxFile1 = getFilenameFile MaxFileName
 
-- remove the trail numbers
maxFile2 = trimRight maxFile1 "1234567890"
 
-- & get the trail numbers as Integer
intTrail = (subString maxFile1 (maxFile1.count-maxFile2.count) maxFile2.count) as Integer
 
-- format it to string with 4 digits
strNumb = formattedPrint (intTrail+1) format:"4.4d"
 
-- build the new file name
newFile = MaxFilePath + maxFile1 + strNumb + ".max"
 
-- & save
saveMaxFile newFile saveAsVersion:2010 quiet:on

my recent MAXScripts RSS (archive here)

barigazy's picture

Hi Anubis. Nice one, but if

Hi Anubis.
Nice one, but if file is not saved before you run this code then

 
maxFile1 = getFilenameFile MaxFileName
-->""
-- remove the trail numbers
maxFile2 = trimRight maxFile1 "1234567890"
-->""
intTrail = (subString maxFile1 (maxFile1.count-maxFile2.count) maxFile2.count) as Integer
-- Error occurred in anonymous codeblock
--  Frame:
-- Runtime error: substring start out of range: 0

First you need to check if MaxFileName != ""

barigazy

Anubis's picture

Yes, I know :)

I think that Ian know this as well and w'd not try to increment unsaved scene, but you're right that the final code need to test for untitled scene.

Also I think that I s'd correct myself (in above code), as there a lot of time gone from my last work with Max :) and I presume that my untested code have some more logical mistakes, especially at the line where I extract the trailing numbers :)

So, if am not wrong, this s'd be more correct:
intTrail = (subString maxFile1 (maxFile2+1) -1) as Integer

my recent MAXScripts RSS (archive here)

barigazy's picture

I fully understand you.

I fully understand you. Beside of that I also agree that every tester even try to detect small errors in the code and optimize the code for yourself.For me this is the most interesting part.
BTW I'm glad you're coming back on the scene. :)

barigazy

W DIGITAL's picture

thank barigazy! do you know

thank barigazy!

do you know how to change this
newFile = MaxFilePath + MaxFileName
saveMaxFile newFile saveAsVersion:2010 clearNeedSaveFlag:false useNewFile:false quiet:true

to use max saveplus command?

max saveplus saves incrementally, but i cannot get it to work with this saveAsVersion code

barigazy's picture

Are you try this script

Are you try this script http://scripts.breidt.net/#incrSave

barigazy

W DIGITAL's picture

no i dont need that one just

no i dont need that one

just need the - max save plus -code to work with saveAsVersion:2010

barigazy's picture

Are you try something like

Are you try something like this

newFile = @"C:\Temp\testFile.max"
saveMaxFile newFile saveAsVersion:2010 clearNeedSaveFlag:false useNewFile:false quiet:true

barigazy

Comment viewing options

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