2010-06-04 23:09:49 +00:00
|
|
|
|
2010-09-03 10:37:35 +00:00
|
|
|
|
|
|
|
-- #################################################################
|
|
|
|
-- ## WARNING : this is a generated file, don't change it !
|
|
|
|
-- #################################################################
|
2010-06-04 23:09:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- Allocate 20 Me for the script
|
|
|
|
heapSize += 15000000
|
|
|
|
|
2010-09-26 15:07:13 +00:00
|
|
|
-- In case of error just abort the app and don't show nel report window
|
|
|
|
NelForceQuitOnMsgDisplayer()
|
|
|
|
|
2010-09-03 10:37:35 +00:00
|
|
|
nlErrorFilename = "%OutputLogfile%"
|
2010-06-04 23:09:49 +00:00
|
|
|
nlErrorStream = openFile nlErrorFilename mode:"a"
|
|
|
|
if nlErrorStream == undefined then
|
|
|
|
nlErrorStream = createFile nlErrorFilename
|
|
|
|
|
|
|
|
-- Unhide category
|
|
|
|
fn unhidecategory =
|
|
|
|
(
|
|
|
|
if (geometry.count > 0) then
|
|
|
|
(
|
|
|
|
unhide geometry[1]
|
|
|
|
if (geometry[1].ishidden == true) then
|
|
|
|
max hide object toggle
|
|
|
|
)
|
|
|
|
if (shapes.count > 0) then
|
|
|
|
(
|
|
|
|
unhide shapes[1]
|
|
|
|
if (shapes[1].ishidden == true) then
|
|
|
|
max hide shape toggle
|
|
|
|
)
|
|
|
|
if (lights.count > 0) then
|
|
|
|
(
|
|
|
|
unhide lights[1]
|
|
|
|
if (lights[1].ishidden == true) then
|
|
|
|
max hide light toggle
|
|
|
|
)
|
|
|
|
if (cameras.count > 0) then
|
|
|
|
(
|
|
|
|
unhide cameras[1]
|
|
|
|
if (cameras[1].ishidden == true) then
|
|
|
|
max hide camera toggle
|
|
|
|
)
|
|
|
|
if (helpers.count > 0) then
|
|
|
|
(
|
|
|
|
unhide helpers[1]
|
|
|
|
if (helpers[1].ishidden == true) then
|
|
|
|
max hide helper toggle
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Log a message
|
|
|
|
fn nlerror message =
|
|
|
|
(
|
|
|
|
if nlErrorStream != undefined then
|
|
|
|
(
|
|
|
|
format "%\n" message to:nlErrorStream
|
|
|
|
flush nlErrorStream
|
|
|
|
)
|
|
|
|
|
|
|
|
-- To the console
|
|
|
|
print message
|
|
|
|
)
|
|
|
|
|
2010-09-03 10:37:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- Some globals
|
|
|
|
|
|
|
|
NEL3D_APPDATA_DONOTEXPORT = 1423062565 -- do not export me : "undefined" = export me
|
|
|
|
-- "0" = export me
|
|
|
|
-- "1" = DONT export me
|
|
|
|
NEL3D_APPDATA_CHARACTER_LOD = 1423062618 -- "1": I am a character lod if "1". "0" or undefined: I am not.
|
|
|
|
|
|
|
|
|
2010-06-04 23:09:49 +00:00
|
|
|
-- Must export this node ?
|
2010-09-03 10:37:35 +00:00
|
|
|
fn isToBeExported node =
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
|
|
|
if ((classof node) == RklPatch) then
|
|
|
|
return false
|
2010-09-03 10:37:35 +00:00
|
|
|
|
2010-06-04 23:09:49 +00:00
|
|
|
if ((classof node) == nel_ps) then
|
|
|
|
return false
|
2010-09-03 10:37:35 +00:00
|
|
|
|
2010-06-04 23:09:49 +00:00
|
|
|
if ((classof node) == nel_pacs_cylinder) then
|
|
|
|
return false
|
2010-09-03 10:37:35 +00:00
|
|
|
|
2010-06-04 23:09:49 +00:00
|
|
|
if ((classof node) == nel_pacs_box) then
|
|
|
|
return false
|
2010-09-03 10:37:35 +00:00
|
|
|
|
2010-06-04 23:09:49 +00:00
|
|
|
doNotExport = getappdata node NEL3D_APPDATA_DONOTEXPORT
|
|
|
|
if (doNotExport != undefined) then
|
|
|
|
(
|
|
|
|
if (doNotExport == "1") then
|
|
|
|
return false
|
|
|
|
)
|
|
|
|
return true
|
|
|
|
)
|
|
|
|
|
2010-09-03 10:37:35 +00:00
|
|
|
|
2010-06-04 23:09:49 +00:00
|
|
|
-- is this node flagged as a LodCharacter ??
|
2010-09-03 10:37:35 +00:00
|
|
|
fn isLodCharacter node =
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
|
|
|
isCLod = getappdata node NEL3D_APPDATA_CHARACTER_LOD
|
|
|
|
if (isCLod == undefined) then
|
|
|
|
return false
|
|
|
|
if (isCLod == "1") then
|
|
|
|
return true
|
|
|
|
return false
|
|
|
|
)
|
|
|
|
|
2010-09-03 10:37:35 +00:00
|
|
|
fn runNelMaxExport inputMaxFile =
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
tagThisFile = true
|
|
|
|
|
|
|
|
-- Unhide category
|
|
|
|
unhidecategory()
|
|
|
|
|
|
|
|
-- Unhide
|
|
|
|
max unhide all
|
|
|
|
|
|
|
|
-- unselect
|
|
|
|
max select none
|
|
|
|
|
|
|
|
-- Exported object count
|
|
|
|
exported = 0
|
|
|
|
|
|
|
|
-- For each node
|
|
|
|
for node in geometry do
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
-- It is root ?
|
|
|
|
if (node.parent == undefined) then
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
-- Can be exported ?
|
|
|
|
if (isToBeExported node == true) then
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
-- Is a Lod character?
|
|
|
|
if ((isLodCharacter node) == true) then
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
-- Output directory
|
|
|
|
outputNelFile = ("%OutputDirectory%/" + (node.name) + ".clod")
|
|
|
|
|
|
|
|
-- Compare file date
|
|
|
|
if (NeLTestFileDate outputNelFile inputMaxFile) == true then
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
try
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
-- Export the shape
|
|
|
|
if (NelExportLodCharacter node outputNelFile false) == true then
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
2010-09-03 10:37:35 +00:00
|
|
|
nlerror("OK " + outputNelFile)
|
|
|
|
exported = exported+1
|
2010-06-04 23:09:49 +00:00
|
|
|
)
|
2010-09-03 10:37:35 +00:00
|
|
|
else
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
|
|
|
-- Error
|
2010-09-03 10:37:35 +00:00
|
|
|
nlerror("ERROR exporting .clod " + node.name + " in file " + inputMaxFile)
|
|
|
|
tagThisFile = false
|
2010-06-04 23:09:49 +00:00
|
|
|
)
|
|
|
|
)
|
2010-09-03 10:37:35 +00:00
|
|
|
catch
|
2010-06-04 23:09:49 +00:00
|
|
|
(
|
|
|
|
-- Error
|
2010-09-03 10:37:35 +00:00
|
|
|
nlerror("ERROR fatal error exporting .clod " + node.name + " in file " + inputMaxFile)
|
|
|
|
tagThisFile = false
|
2010-06-04 23:09:49 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
else
|
|
|
|
(
|
|
|
|
-- Error
|
2010-09-03 10:37:35 +00:00
|
|
|
nlerror("SKIPPED " + outputNelFile)
|
|
|
|
exported = exported + 1
|
2010-06-04 23:09:49 +00:00
|
|
|
)
|
2010-09-03 10:37:35 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Something exported
|
|
|
|
if (exported == 0) then
|
|
|
|
(
|
|
|
|
-- Error
|
|
|
|
nlerror ("WARNING no .clod exported from the file " + inputMaxFile)
|
|
|
|
)
|
|
|
|
|
|
|
|
return tagThisFile
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-09-26 15:07:13 +00:00
|
|
|
removeRunningTag = true
|
|
|
|
|
2010-09-03 10:37:35 +00:00
|
|
|
try
|
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
undo off
|
2010-09-03 10:37:35 +00:00
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
-- Get files in the %MaxSourceDirectory% directory
|
|
|
|
files = getFiles "%MaxSourceDirectory%/*.max"
|
|
|
|
gc()
|
|
|
|
|
|
|
|
-- Sort files
|
|
|
|
sort files
|
|
|
|
gc()
|
|
|
|
|
|
|
|
-- No file ?
|
|
|
|
if files.count != 0 then
|
2010-09-03 10:37:35 +00:00
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
-- For each files
|
|
|
|
for i = 1 to files.count do
|
2010-09-03 10:37:35 +00:00
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
inputMaxFile = files[i]
|
|
|
|
outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag")
|
|
|
|
|
|
|
|
--try
|
|
|
|
--(
|
|
|
|
-- Compare file date
|
|
|
|
if (NeLTestFileDate outputTagFile inputMaxFile) == true then
|
2010-09-03 10:37:35 +00:00
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
-- Free memory and file handles
|
|
|
|
gc()
|
|
|
|
heapfree
|
2010-09-03 10:37:35 +00:00
|
|
|
|
2010-09-26 15:07:13 +00:00
|
|
|
-- Reset 3dsmax
|
|
|
|
resetMAXFile #noprompt
|
|
|
|
|
|
|
|
-- Open the max project
|
|
|
|
nlerror("Scanning file " + inputMaxFile + " ...")
|
|
|
|
if (loadMaxFile inputMaxFile quiet:true) == true then
|
2010-09-03 10:37:35 +00:00
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
tagThisFile = runNelMaxExport(inputMaxFile)
|
|
|
|
|
|
|
|
-- Write a tag file
|
|
|
|
if tagThisFile == true then
|
2010-09-03 10:37:35 +00:00
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
tagFile = createFile outputTagFile
|
|
|
|
if tagFile == undefined then
|
|
|
|
(
|
|
|
|
nlerror("WARNING can't create tag file " + outputTagFile)
|
|
|
|
removeRunningTag = false
|
|
|
|
)
|
|
|
|
else
|
|
|
|
(
|
|
|
|
print "mukyu" to: tagFile
|
|
|
|
close tagFile
|
|
|
|
)
|
2010-09-03 10:37:35 +00:00
|
|
|
)
|
|
|
|
else
|
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
removeRunningTag = false
|
2010-09-03 10:37:35 +00:00
|
|
|
)
|
|
|
|
)
|
2010-09-26 15:07:13 +00:00
|
|
|
else
|
|
|
|
(
|
|
|
|
-- Error
|
|
|
|
nlerror("ERROR exporting 'clod': can't open the file " + inputMaxFile)
|
|
|
|
removeRunningTag = false
|
|
|
|
)
|
2010-09-03 10:37:35 +00:00
|
|
|
)
|
|
|
|
else
|
|
|
|
(
|
2010-09-26 15:07:13 +00:00
|
|
|
nlerror("SKIPPED BY TAG " + inputMaxFile)
|
2010-09-03 10:37:35 +00:00
|
|
|
)
|
2010-09-26 15:07:13 +00:00
|
|
|
--)
|
|
|
|
--catch
|
|
|
|
--(
|
|
|
|
-- -- Error
|
|
|
|
-- nlerror("ERROR error exporting 'clod' in file " + inputMaxFile)
|
|
|
|
-- removeRunningTag = false
|
|
|
|
--)
|
2010-09-03 10:37:35 +00:00
|
|
|
)
|
2010-06-04 23:09:49 +00:00
|
|
|
)
|
2010-09-26 15:07:13 +00:00
|
|
|
else
|
|
|
|
(
|
|
|
|
nlerror("WARNING no *.max file in folder %MaxSourceDirectory%")
|
|
|
|
)
|
2010-06-04 23:09:49 +00:00
|
|
|
)
|
|
|
|
)
|
2010-09-03 10:37:35 +00:00
|
|
|
catch
|
|
|
|
(
|
|
|
|
-- Error
|
|
|
|
nlerror("ERROR fatal error exporting 'clod' in folder %MaxSourceDirectory%")
|
2010-09-26 15:07:13 +00:00
|
|
|
removeRunningTag = false
|
2010-09-03 10:37:35 +00:00
|
|
|
)
|
2010-06-04 23:09:49 +00:00
|
|
|
|
2010-09-26 15:07:13 +00:00
|
|
|
try
|
|
|
|
(
|
|
|
|
if (removeRunningTag) then
|
|
|
|
(
|
|
|
|
resetMAXFile #noPrompt
|
|
|
|
)
|
|
|
|
)
|
|
|
|
catch
|
|
|
|
(
|
|
|
|
nlerror("FAIL Last reset fails")
|
|
|
|
removeRunningTag = false
|
|
|
|
)
|
2010-06-04 23:09:49 +00:00
|
|
|
|
2010-09-26 15:07:13 +00:00
|
|
|
if (removeRunningTag) then
|
|
|
|
(
|
|
|
|
nlerror("SUCCESS All .max files have been successfully exported")
|
|
|
|
deleteFile("%TagDirectory%/max_running.tag")
|
|
|
|
)
|
|
|
|
else
|
|
|
|
(
|
|
|
|
nlerror("FAIL One or more issues occured")
|
|
|
|
NelForceQuitRightNow()
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Bye
|
|
|
|
nlerror("BYE")
|
2010-06-04 23:09:49 +00:00
|
|
|
quitMAX #noPrompt
|
2010-09-03 10:37:35 +00:00
|
|
|
quitMAX() #noPrompt
|
2010-06-04 23:09:49 +00:00
|
|
|
|