max script batch export ??

max script batch export ??

Anonymous
Not applicable
683 Views
2 Replies
Message 1 of 3

max script batch export ??

Anonymous
Not applicable
Hi I’m new to scripting , ive got a scene with 3oo models and I need to export ( selected )
Them one by one with Panda Direct x. file by hand its taking forever could and one help thanks
0 Likes
684 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
it can actually be done pretty simply, but here is a couple functions that you can use with a few more options.


--wanky recursive function to parse hierarchy into an array
fn addChildrenToArray theChildren currentObjsToExport =
(
for c in theChildren do
(
append currentObjsToExport c
addChildrenToArray c.children currentObjsToExport
)
)

-- Export the selection.. with the option to export each selected object seperately (hier:false) or to export each hierarchy to seperate objects (hier:true)
-- exported filenames will be the same as the
fn massExportfn hier path filetype =
(

exportSelection = selection as array
--if we're doing seperate hierarchys, then only keep the objects that have no parent in the selection
if hier == true then
(
baseNodesToExport = for o in exportSelection where o.parent == undefined collect o
)
else baseNodesToExport = exportSelection

--parse through said root nodes
for o in baseNodesToExport do
(
--save old position, export at 0,0,0, restore to old position
oldPos = o.position
o.position =

--children returns a 'NodeChildrenArray, so convert that to an array manually.
--include the current node in the array no matter what.
currentObjsToExport = #(o)

-- if we're packaging hierarchys then collect childrem
if hier == true do
(
addChildrenToArray o.children currentObjsToExport
)

select currentObjsToExport

--random info for use to ogle at the export.. yea yea
format "\tExport:\t%\tas\t%\n" o.name filetype
format "\tTo:\t%\n" (path + "/" + o.name + filetype)
format "\n-----------------------------\n\n"

-- if we need to save selected use this export type to blow the objects out to maxfiles
if filetype == ".MAX" then ( savenodes currentObjsToExport (path + "/" + o.name + filetype) quiet:true )
else
(
--export using the name of the root node as the filename
exportfile (path + "/" + o.name + filetype) #noPrompt selectedOnly:true
)
o.position = oldPos
)
select exportSelection
)

massExportfn true "C:\Temp" ".X"
0 Likes
Message 3 of 3

Anonymous
Not applicable
thanks you have saved my life 😉
0 Likes