[Closed] MaxScript – Save as Archive
Hi All,
I can save the project via saveMaxFile as a .max without any problem.
But what if I want to do something like Max’s save as archive option. I mean, collect everything and save it as a zip archive to a given path?
Is it possible with MaxScript?
Thanks…
Thank you for your suggestion SamSed. It really worked. My Code is like following.
(
renderSceneDialog.close()
Cams = for Cam in cameras where (superclassof Cam == camera) collect Cam
Width = renderWidth as string
Height = renderHeight as string
File = rendOutputFilename as string
rendTimeType = 2
FF = animationrange.start as string
LF = animationRange.end as string
VerBase = (maxVersion())[1]/1000
If VerBase > 12 then
Ver = Verbase + 1998
else
Ver = "Pre 2011"
if Cams.count > 0 then
(
output_name = ((maxfilepath)+"/ProjectInfo.xml")
if output_name != undefined then
(
output_file = createfile output_name
if output_file != undefined then
(
format "%
" "<xml>" to:output_file
format "%
" "<Version>" to:output_file
format "<Version>%</Version>
" Ver to:output_file
format "%
" "</Version>" to:output_file
format "%
" "<Renderer>" to:output_file
format "<renderer>%</renderer>
" renderers.current to:output_file
format "%
" "</Renderer>" to:output_file
format "%
" "<Cameras>" to:output_file
for Cam in Cams do format "<camera>%</camera>
" Cam.name to:output_file
format "%
" "</Cameras>" to:output_file
format "%
" "<FrameRange>" to:output_file
format "<start>%</start>
" FF to:output_file
format "<end>%</end>
" LF to:output_file
format "%
" "</FrameRange>" to:output_file
format "%
" "<Resolution>" to:output_file
format "<width>%</width>
" width to:output_file
format "<height>%</height>
" height to:output_file
format "%
" "</Resolution>" to:output_file
format "%
" "<OutputInfo>" to:output_file
format "<outfile>%</outfile>
" File to:output_file
format "%
" "</OutputInfo>" to:output_file
format "%
" "</xml>" to:output_file
close output_file
)
)
)
rendOutputFilename = ""
max file archive
)
It obviously creates an XML file just next to the project file. I am pretty sure that there are more efficient ways to do the same, but this one is more than enough to satisfy my needs.
My next challenge is including this XML file into the created archive.
As per my google research as a newbie, it can be possible via marking the XML file as an asset of the project. Looks like setMaxFileAssetMetadata is the correct tool to achieve this, but after an extensive search and multiple tries I am out of ideas.
Any suggestions about this?
Thanks in Advance…
it can be possible via marking the XML file as an asset of the project. Looks like setMaxFileAssetMetadata is the correct tool to achieve this, but after an extensive search and multiple tries I am out of ideas.
I’m not very familiar with setMaxFileAssetMetadata. so i can’t help with that.
However, i’ll do it this way (maybe there are other better ways). Add that file as a new custom dependency in the asset tracking system (ATS) and then zip the whole thing with maz() function.
Your code will look like this:
(
renderSceneDialog.close()
Cams = for Cam in cameras where (superclassof Cam == camera) collect Cam
Width = renderWidth as string
Height = renderHeight as string
File = rendOutputFilename as string
rendTimeType = 2
FF = animationrange.start as string
LF = animationRange.end as string
VerBase = (maxVersion())[1]/1000
If VerBase > 12 then
Ver = Verbase + 1998
else
Ver = "Pre 2011"
if Cams.count > 0 then
(
output_name = ((maxfilepath)+"/ProjectInfo.xml")
if output_name != undefined then
(
output_file = createfile output_name
if output_file != undefined then
(
format "%
" "<xml>" to:output_file
format "%
" "<Version>" to:output_file
format "<Version>%
" Ver to:output_file
format "%
" "</Version>" to:output_file
format "%
" "<Renderer>" to:output_file
format "<renderer>%
" renderers.current to:output_file
format "%
" "</Renderer>" to:output_file
format "%
" "<Cameras>" to:output_file
for Cam in Cams do format "<camera>%
" Cam.name to:output_file
format "%
" "</Cameras>" to:output_file
format "%
" "<FrameRange>" to:output_file
format "<start>%
" FF to:output_file
format "<end>%
" LF to:output_file
format "%
" "</FrameRange>" to:output_file
format "%
" "<Resolution>" to:output_file
format "<width>%
" width to:output_file
format "<height>%
" height to:output_file
format "%
" "</Resolution>" to:output_file
format "%
" "<OutputInfo>" to:output_file
format "<outfile>%
" File to:output_file
format "%
" "</OutputInfo>" to:output_file
format "%
" "</xml>" to:output_file
close output_file
)
)
)
rendOutputFilename = ""
ATSCustomDepsOps.AddFile output_name [color=Pink]-- Add the newly created XML file into the ATS
ATSOps.Refresh()
local Asset = #()
ATSOps.GetFiles &Asset --collect all scene files and paths
archive = (maxfilepath+ (getFilenameFile maxFileName) + ".zip")-- For simplicity sake your zip file will be located in the same folder as your max file, replace maxfilepath with a folder of your choosing with getSavePath()
maz archive Asset[/color] -- archive the project
)
Hope this helps a bit.
this code Error in #Line
ATSCustomDepsOps.AddFile output_name – Add the newly created XML file into the ATS
I want this code in cmd
for %a in (13 14) do “D:\setup\Autodesk\3ds Max Design 2014\3dsmaxcmd.exe” -rfw:0 -continueOnError “F:\a37 (%a).max” -bitmapPath:“F:\TEXTURE” -rps:“D:\desktop\presents.rps” -width:500 -height:500 -o=d:\desktop\r\a37%a.jpg -preRenderScript:“D:\desktop[B]MAXSCRIPT[/B].ms”
MAXSCRIPT= upcode.
??