doCHtor
04-14-2008, 11:50 AM
Hi,
I have written a script for batch importing fbx files and then saving max files and bip files.
Only problem I have is that when i run the script in freshly started max, it will crash until i reinstall it. Running it twice doesn't help. Only reinstalling helps.
Script is crashing on a function where i'm configuring fbx importer with error: >> MAXScript Rollout Handler Exception: -- Type error: Call needs function or class, got: undefined <<
and this is the line where the scripts ends: FbxImporterSetParam "Mode" "exmerge"
This is the script:
try(destroyDialog ImporterIzer)catch()
rollout ImporterIzer "ImporterIzer™" width:300 height:255
(
local ImportOn
local ImportPath
local ExportPath
local ImportFiles
local filename
--UI DEFINITION
Group "Files:"
(
Label LabImportOn "Import on:" across:3 align:#left
.
.
)
Group "Options:"
(
Label LabExportToExportSubfolder "Export files to Export sub-folder in Import folder:" across:2 align:#left
.
.
)
Group "Progress:"
(
ProgressBar ProgImportProgress "ProgressBar" color:[255,135,7]
)
fn ImportFbxSettings =
(
pluginManager.loadClass FBXIMP
FbxImporterSetParam "Mode" "exmerge" -- Import options
FbxImporterSetParam "Geometries" false -- whether to import geometries
FbxImporterSetParam "Skin" false -- whether to import scene's skin
.
.
.
)
on ButDoTheMagic pressed do
(
if ImportOn != undefined then
if (getFiles ImportOn).count != 0 then
if ImportPath != undefined then
if (getDirectories ImportPath).count != 0 then
if CheckExportToExportSubfolder.tristate != 2 or CheckExportToExportSubfolder.tristate == 2 and (getDirectories ExportPath).count != 0 then
(
ImportFiles = getFiles (ImportPath + "\\*.fbx" )
if ImportFiles.count > 0 then
(
for I=1 to ImportFiles.count do
(
loadMaxFile ImportOn useFileUnits:true quiet:true
ImportFbxSettings()
filename = getFilenameFile ImportFiles[i]
if CheckExportToExportSubfolder.tristate == 1 then
(
MakeDir (ImportPath + "\\Export")
ExportPath = (ImportPath + "\\Export")
)
else if CheckExportToExportSubfolder.tristate == 0 then
ExportPath = ImportPath
importFile ImportFiles[I] #noPrompt using:importerPlugin.classes[5]
if CheckSaveBip.tristate == 1 then SaveBip()
if CheckResetPinePos.tristate == 1 then ResetPinePos()
saveMaxFile (ExportPath + "\\" + filename + ".max")
ProgImportProgress.value = 100.0*I/ImportFiles.count
)
Messagebox "Hey boss, the job is done!" title:"Terrible success!"
)
else messagebox "There are NO files to import in the specified Import folder" title:"Horrible error!"
)
else messagebox "Export path no longer exists" title:"Horrible error!"
else messagebox "Import path no longer exists" title:"Horrible error!"
else messagebox "Import folder was not specified" title:"Horrible error!"
else messagebox "Import on file no longer exists" title:"Horrible error!"
else messagebox "Import on file was not specified" title:"Horrible error!"
)
)
createdialog ImporterIzer
I have left out the parts of the code with "on button pressed do", if needed, I can post the whole script.
Any ideas what I'm doing wrong? Some bad declaration?
Also, FbxImporterSetParam "YUpZUp" <bool> doesn't seem to work.
Thanks.
I have written a script for batch importing fbx files and then saving max files and bip files.
Only problem I have is that when i run the script in freshly started max, it will crash until i reinstall it. Running it twice doesn't help. Only reinstalling helps.
Script is crashing on a function where i'm configuring fbx importer with error: >> MAXScript Rollout Handler Exception: -- Type error: Call needs function or class, got: undefined <<
and this is the line where the scripts ends: FbxImporterSetParam "Mode" "exmerge"
This is the script:
try(destroyDialog ImporterIzer)catch()
rollout ImporterIzer "ImporterIzer™" width:300 height:255
(
local ImportOn
local ImportPath
local ExportPath
local ImportFiles
local filename
--UI DEFINITION
Group "Files:"
(
Label LabImportOn "Import on:" across:3 align:#left
.
.
)
Group "Options:"
(
Label LabExportToExportSubfolder "Export files to Export sub-folder in Import folder:" across:2 align:#left
.
.
)
Group "Progress:"
(
ProgressBar ProgImportProgress "ProgressBar" color:[255,135,7]
)
fn ImportFbxSettings =
(
pluginManager.loadClass FBXIMP
FbxImporterSetParam "Mode" "exmerge" -- Import options
FbxImporterSetParam "Geometries" false -- whether to import geometries
FbxImporterSetParam "Skin" false -- whether to import scene's skin
.
.
.
)
on ButDoTheMagic pressed do
(
if ImportOn != undefined then
if (getFiles ImportOn).count != 0 then
if ImportPath != undefined then
if (getDirectories ImportPath).count != 0 then
if CheckExportToExportSubfolder.tristate != 2 or CheckExportToExportSubfolder.tristate == 2 and (getDirectories ExportPath).count != 0 then
(
ImportFiles = getFiles (ImportPath + "\\*.fbx" )
if ImportFiles.count > 0 then
(
for I=1 to ImportFiles.count do
(
loadMaxFile ImportOn useFileUnits:true quiet:true
ImportFbxSettings()
filename = getFilenameFile ImportFiles[i]
if CheckExportToExportSubfolder.tristate == 1 then
(
MakeDir (ImportPath + "\\Export")
ExportPath = (ImportPath + "\\Export")
)
else if CheckExportToExportSubfolder.tristate == 0 then
ExportPath = ImportPath
importFile ImportFiles[I] #noPrompt using:importerPlugin.classes[5]
if CheckSaveBip.tristate == 1 then SaveBip()
if CheckResetPinePos.tristate == 1 then ResetPinePos()
saveMaxFile (ExportPath + "\\" + filename + ".max")
ProgImportProgress.value = 100.0*I/ImportFiles.count
)
Messagebox "Hey boss, the job is done!" title:"Terrible success!"
)
else messagebox "There are NO files to import in the specified Import folder" title:"Horrible error!"
)
else messagebox "Export path no longer exists" title:"Horrible error!"
else messagebox "Import path no longer exists" title:"Horrible error!"
else messagebox "Import folder was not specified" title:"Horrible error!"
else messagebox "Import on file no longer exists" title:"Horrible error!"
else messagebox "Import on file was not specified" title:"Horrible error!"
)
)
createdialog ImporterIzer
I have left out the parts of the code with "on button pressed do", if needed, I can post the whole script.
Any ideas what I'm doing wrong? Some bad declaration?
Also, FbxImporterSetParam "YUpZUp" <bool> doesn't seem to work.
Thanks.
