Essentially what this script dose is it takes each object in a scene and saves it out. It also uses the objects center as the center of the scene it save out for each object, which might be a problem, but the important thing is that is saves each object as a separate file.
How this is helpful is when someone is exporting an object with animations, usually they need use the snapshot tool in Max to make one object for every frame of animation your mesh has. Then take each object and save them by themselves in separate files for every frame of animation you have. Considering that some animations can be as much as 1000 frames saving each one out by hand is time consuming and repetitive task.
What you can do instead is when you make your snapshot for every frame of animation you can use this script to save out each object as a separate file for import into Deus Ex. This is a lot less time consuming then doing it by hand.
Code: Select all
macroScript KeensBatchExporter category:"File"
(
--///////////////////////////////////////////////////
--This MaxScript started out as a simple test that
--would allow you to export objects using their pivot
--as the scene origin(so if you had 5 objects
--scattered around the scene it would move them to
--0,0,0 for export then move them back after export is
--done).I got a request for batch operations in the
--script and thought that would be a nice feature so
--i did some research on that and now the script allows
--you to batch export to any format that 3ds max
--supports and use the scene object name as the file
--name. You can choose to export only selected
--(or unselected) objects, or export all objects in
--the scene. It also allows you to add prefixes to
--the beginning and/or end of the file name on export,
--or add them to the scene object name.
--///////////////////////////////////////////////////
global prefixpopupgui
--global PrefixText = name()
fn DoExport outputpath ext useobjpivot exportsetup exportsel invertsel pfxb pfxbs pfxa pfxas =
(
if (outputpath != undefined) do
(
OldSelection = getCurrentSelection()
if (not exportsel) then
max select all
else if (invertsel) then
max select invert
objList = getCurrentSelection()
for p=1 to objList.count do
(
if (pfxb != "") then
Prefix1 = pfxb + pfxbs
else
Prefix1 = ""
if (pfxa != "") then
Prefix2 = pfxa + pfxas
else
Prefix2 = ""
exportName = outputPath + "\\" + Prefix1 + objList[p].name + Prefix2 + "." + ext
select objList[p]
if (useobjpivot) do
(
OldPosition = $.Position
$.position = [0,0,0]
)
if (exportsetup and p == 1) then
exportfile exportName selectedOnly:TRUE
else
exportfile exportName #noPrompt selectedOnly:TRUE
if (useobjpivot) then
$.Position = OldPosition
if (p == objList.count) then
select OldSelection --reselect old selection
) --end for
) --end if
) --end fn
fn DoMaxSave outputpath useobjpivot exportsel invertsel pfxb pfxbs pfxa pfxas =
(
if (outputpath != undefined) do
(
OldSelection = getCurrentSelection()
if (not exportsel) then
max select all
else if (invertsel) then
max select invert
objList = getCurrentSelection()
for p=1 to objList.count do
(
if (pfxb != "") then
Prefix1 = pfxb + pfxbs
else
Prefix1 = ""
if (pfxa != "") then
Prefix2 = pfxas + pfxa
else
Prefix2 = ""
saveName = outputPath + "\\" + Prefix1 + objList[p].name + Prefix2 + ".max"
select objList[p]
if (useobjpivot) do
(
OldPosition = $.Position
$.position = [0,0,0]
)
max views redraw
saveNodes selection saveName
if (useobjpivot) then
$.Position = OldPosition
if (p == objList.count) then
select OldSelection --reselect old selection
) --end for
) --end if
) --end fn
fn DoPrefixToObject pfxb pfxbs pfxa pfxas =
(
objList = getCurrentSelection()
for p=1 to objList.count do
(
Prefix1 = pfxb + pfxbs
Prefix2 = pfxas + pfxa
ChangeNameTo = Prefix1 + objList[p].name + Prefix2
select objList[p]
$.name = ChangeNameTo
) --end for
)
--Start GUI
rollout prefixpopup "Add Prefix To Object Name" width:446 height:130
(
GroupBox grp48 "Prefix Warning" pos:[2,6] width:252 height:120
label lbl164 "WARNING! You are about to add one or more Prefixes to the the names of all currently selected Objects. Are you sure you want to continue?" pos:[8,24] width:240 height:45
button clickyes "Yes" pos:[96,88] width:64 height:24
edittext newpfxb "" pos:[262,45] width:125 height:20
GroupBox grp96 "AddPrefix" pos:[259,7] width:184 height:111
edittext newpfxbs "" pos:[388,45] width:48 height:20
label lbl308 "Prefix before name" pos:[265,29] width:100 height:16
label lbl309 "Separator" pos:[387,29] width:48 height:16
edittext newpfxa "" pos:[262,90] width:125 height:20
edittext newpfxas "" pos:[388,90] width:48 height:20
label lbl310 "Prefix after name" pos:[265,74] width:83 height:16
label lbl311 "Separator" pos:[387,74] width:48 height:16
on clickyes pressed do
(
DoPrefixToObject newpfxb.text newpfxbs.text newpfxa.text newpfxas.text
--closeRolloutFloater prefixpopupgui
)
on clickno pressed do
(
closeRolloutFloater prefixpopupgui
)
)
rollout base "Batch Export" width:188 height:480
(
label lbl1 "Output Directory" pos:[4,32] width:105 height:16
edittext outputpath "" pos:[0,48] width:156 height:20
label lbl2 "Extension (ase=good .ase=bad)" pos:[4,80] width:159 height:16
edittext editExt "" pos:[0,96] width:36 height:20
button kExport "EXPORT" pos:[12,128] width:60 height:26
checkbox useobjpivot "Checkbox" pos:[8,178] width:16 height:16 checked:true
GroupBox grp1 "Output" pos:[2,8] width:184 height:113
GroupBox grp2 "Modify" pos:[2,158] width:184 height:129
label lbl12 "Use Object Pivot As Origin" pos:[24,178] width:129 height:16
button DirLookUp "..." pos:[160,48] width:16 height:20
checkbox exportsetup "Checkbox" pos:[8,198] width:16 height:16 checked:true
label lbl25 "Configure Export Settings" pos:[24,198] width:129 height:16
edittext pfxb "" pos:[5,355] width:125 height:20
GroupBox grp15 "AddPrefix" pos:[2,317] width:184 height:111
edittext pfxbs "" pos:[131,355] width:48 height:20
label lbl40 "Prefix before name" pos:[8,339] width:100 height:16
label lbl41 "Separator" pos:[130,339] width:48 height:16
edittext pfxa "" pos:[5,400] width:125 height:20
edittext pfxas "" pos:[131,400] width:48 height:20
label lbl78 "Prefix after name" pos:[8,384] width:83 height:16
label lbl79 "Separator" pos:[130,384] width:48 height:16
checkbox exportsel "Checkbox" pos:[8,218] width:16 height:16 checked:true
label lbl128 "Export Only Selected Meshes" pos:[24,218] width:147 height:16 enabled:true
checkbox invertsel "Checkbox" pos:[8,238] width:16 height:16 checked:false
label lbl129 "Invert Selection" pos:[24,238] width:129 height:16
checkbox savemax "Checkbox" pos:[40,98] width:16 height:16 enabled:true checked:false
label lbl193 "Save As .MAX file" pos:[56,98] width:90 height:16
button savemaxbutton "Save .MAX files" pos:[88,128] width:80 height:26 enabled:false
button prefix2object "Asign prefixes to object names" pos:[16,293] width:156 height:20
on kExport pressed do
(
if (outputpath.text == "" and editExt.text == "") then
messagebox("Please specify an output directory and a file extension.")
else if (outputpath.text == "") then
messagebox("Please specify an output directory.")
else if (editExt.text == "") then
messagebox("Please specify a file extension.")
else if (not doesFileExist outputpath.text) then
messagebox("'" + outputpath.text + "'" + " does not exist, please enter a valid output directory.")
else
DoExport outputpath.text editExt.text useobjpivot.state exportsetup.state exportsel.state invertsel.state pfxb.text pfxbs.text pfxa.text pfxas.text
)
on DirLookUp pressed do
(
outputpath.text = getSavePath "Save to:"
)
on exportsel changed state do
(
if (exportsel.checked == true) then
(
invertsel.enabled = true
)
else
(
invertsel.enabled = false
invertsel.checked = false
)
)
on savemax changed state do
(
if (savemax.checked == true) then
(
editExt.enabled = false
savemaxbutton.enabled = true
kExport.enabled = false
)
else
(
editExt.enabled = true
savemaxbutton.enabled = false
kExport.enabled = true
)
)
on savemaxbutton pressed do
(
if (outputpath.text == "") then
messagebox("Please specify an output directory.")
else if (not doesFileExist outputpath.text) then
messagebox("'" + outputpath.text + "'" + " does not exist, please enter a valid output directory.")
else
DoMaxSave outputpath.text useobjpivot.state exportsel.state invertsel.state pfxb.text pfxbs.text pfxa.text pfxas.text
)
on prefix2object pressed do
(
prefixpopupgui = newRolloutFloater "Prefix to Object" 454 164
addRollout prefixpopup prefixpopupgui
)
)
rollout info "info/contact" width:188 height:430
(
GroupBox grp48 "Contact" pos:[2,6] width:184 height:79
label lbl160 "author:" pos:[8,21] width:160 height:16
label lbl161 "Kurt'commander_keen'Loeffler" pos:[8,35] width:160 height:16
label lbl162 "email:" pos:[9,49] width:160 height:16
label lbl163 "kurtloeffler@gmail.com" pos:[9,63] width:162 height:16
GroupBox grp53 "Info" pos:[2,97] width:184 height:306
label lbl164 "This MaxScript started out as a simple test that would allow you to export objects using their pivot as the scene origin(so if you had 5 objects scattered around the scene it would move them to 0,0,0 for export then move them back after export is done).I got a request for batch operations in the script and thought that would be a nice feature so i did some research on that and now the script allows you to batch export to any format that 3ds max supports and use the scene object name as the file name. You can choose to export only selected (or unselected) objects, or export all objects in the scene. It also allows you to add prefixes to the beginning and/or end of the file name on export, or add them to the scene object name." pos:[8,112] width:170 height:289
)
gui = newRolloutFloater "BatchExport" 192 480
addRollout base gui
addRollout info gui
)
Code: Select all
----------------------------------------------------------
Batch exports all selected models as .ASE individually.
Places objects at 0,0,0 automatically and puts them back to their original position. (Make sure that your pivot point is correct!)
Uses object name as .ASE filename
Can add prefixes to the filename
How to use : Put in Max\Scripts
Once in Max, Top menu > MaxScript > Run Script > select file and run. Then Top menu > Customize > Customize User Interface -> Toolbars -> Search for Keenbatchexport and drag to a toolbar, (example deafault top toolbar) Click new button
----------------------------------------------------------
Additionals notes in the KeensBatchExporter.ms (can be opened with notepad)