technical architecture.

Mass Exporting, again

by on Feb.24, 2009, under Batching, maxscript, utility

Mass exporting..

We have a fun little virtools app that loads in various NMO’s exported out from max on the fly as needed based on user input, so in the process of working out what our process would be, we came to the need to have each seperate 3dsmax hierarchy exported out into a seperate virtools NMO file.

Pretty simple, but the question came up on a forum today and its been a useful little script that I’ve been using for years now.

the guts are:

--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
fn massExportfn hier path filetype =
	exportSelection = selection as array
	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 
		oldPos = o.position
		o.position = [0,0,oldPos.z]
		--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" filetype
		format "\tTo:\t%\n" (path + "/" + + filetype)
		format "\n-----------------------------\n\n"
		-- if we need to save selected use this export type
		if filetype == ".MAX" then
			savenodes currentObjsToExport (path + "/" + + filetype) quiet:true
			--export using the name of the root node as the filename
			exportfile (path + "/" + + filetype) #noPrompt selectedOnly:true 
		o.position = oldPos
	select exportSelection
-- and its used by:
massExportfn true "C:/temp/" ".vmo"

Theres an interface for it here, but i’ve got it built into many other small little pipeline specific utils, so that may not be of any real use to anyone else, but this little snip might be useful for someone out there.

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!