--**************************************
--* export_OBJ.ms :
--* The script is used to help with the export
--* of parts to OpenPlane Studio, or any other
--* program for that matter. It resets each
--* object back to its identity matrix (pivot
--* point to origin, rotations removed), exports
--* to a OBJ file and then returns the objects
--* back to the original matrix
--*
--***************************************
--* Forward declare the saved matrix list
--*
old_mat = #()
--**************************************
--* Change this to where you really want
--* the exported file to be
--*
export_filename = "d:\sdoe\hurricane.obj"
--**************************
--* This uses an incremented integer
--* rather than object iteration because
--* it needs the index for the saved list
--*
--* Note that this will re-position all
--* objects including cameras and lights
--* and helpers. You could refine it by using
--* the 'geometry' collection rather than
--* 'objects' but it doesn't make much
--* difference to the end result
--*
for i=1 to objects.count do
(
--**************************
--* Save the Existing Matrix
--* Information
--*
old_mat[i] = objects[i].transform
--****************************
--* Set to the Identity Matrix
--*
objects[i].transform=matrix3 1
)
--************************************
--* Export the file. Note that MAXr2.5 doesn't
--* Support "max file export" which will provide
--* a nice file selection dialog. However
--* exportFile does have its advantages in that
--* the file export will happen without user
--* intervention. Since MAX2OBJ saves the last
--* settings, you can either do a manual export
--* with the setting you want, or remove the
--* '#noPrompt' to get the MAX2OBJ dialogs.
--* For MAX r3.0 users who want the file selection
--* dialog replace this line with
--*
--* max file export
--*
exportFile export_filename #noPrompt
--***********************************
--* Now back to your regular programming!
--*
for i=1 to objects.count do
(
objects[i].transform= old_mat[i]
)