ScriptSpot

Forum topic · General Scripting

3ds2max+dwg2max

By ubikstudio · 2011-04-14

Description

hi all,

i need to convert many 3ds to max in the same folder with the same name..a lot of work if i have to do it one by one...

is there a scrip or plugin to do this..

and the same question with dwg or dxf to max..

thanks a lot

Comments (9)

ubikstudio · 2011-04-18

oh thanks...great!!

thanks a lot..

yu thin its hard to ad "buton

ubikstudio · 2011-04-15

you think its hard to ad "buton to processes subfolder?

:)
thanks..

Anubis · 2011-04-15

As you see, nothing hard here.
You can create a rollout or utility, add a button and it event, right?
Im super busy right now, but here is a quick instruction:

utility MeshDirToMax "Mesh Dir To Max"
(
	button btnDir "My Folder to .MAX" width:120
	on btnDir pressed do
	(
---------// paste my code here...
	)
)

That's it :)
Ok, finally I attached the updated script, cheers!

Attachments

ubikstudio · 2011-04-15

oh thanks anubis..i see your comment after my post

thanks a lot work great....

ubikstudio · 2011-04-15

i fond a script from Larry Minton
work good..but how can i autosave to the same name as the *.3ds

thanks..

rollout LoadAndSaveAll "Load and Resave All" (

-- general locals
local files, sourceDir
local processTheScene, collectFileNames, existFile, existDir, makeDirPath, getTheFile, stripBasePath
local debug=false
local filesToProcess="*.3ds"

-- script process specific locals

-- this function is called to load the file
fn getTheFile theFile=loadMaxFile theFile

-- this function is called after the file is loaded.
-- If the scene is processed ok, return true. Otherwise return false.
-- The name of the file and the filestream for logging are the parameters
fn processTheScene theFile logfile =
( redrawViews()
max file save
true
)

-- this function is called to collect all the files in a base directory with a given extension.
-- if subdirs:true is specified, files in subdirectories are also collected
fn collectFileNames baseDir ext subdirs:false fileList: =
( --format "Processing: %\n" baseDir
if fileList == unsupplied do (fileList=#(); if baseDir[baseDir.count] != "\\" do baseDir += "\\")
-- get the files with the specified extension in this directory
for fname in (getFiles (baseDir+ext)) do append fileList fname
-- recursively process each subdirectory
if subdirs do
for aDir in (getDirectories (baseDir+"*.*")) do
collectFileNames aDir ext subdirs:true fileList:fileList
fileList
)

-- a function to determine if a file exists
fn existFile fname = (getfiles fname).count != 0

-- a function to determine if a directory exists
fn existDir dname =
( if dname[dname.count] == "\\" or dname[dname.count] == "/" do dname=substring dname 1 (dname.count-1)
(getDirectories dname).count != 0
)

-- a function to create a directory path structure. Returns true if success
-- have to make each directory in the path structure separately
fn makeDirPath theDir =
( local parsedDir = filterstring theDir "\\"
local dirString = parsedDir[1] -- the drive
for i=2 to parsedDir.count do
( dirString += "//"+parsedDir[i]
if not (existDir dirString) do
if not (makeDir dirString) do return false
)
true
)

-- a function to strip the base directory from the file name in the array of file names
fn stripBasePath baseDir files=
( local baseDirLen=baseDir.count+1
for i=1 to files.count do files[i]=substring files[i] baseDirLen -1
)

-- define the user interface
Button aboutProcessAll "About..."
Label srclbl "Source Directory:" offset:[0,5]
Button SourcePath "--none--" width:150
checkbox doSubDirs "Process subdirectories" checked:true offset:[-8,0]
label num2process_t "# Files to process:" across:2 align:#left offset:[0,5]
label numFilesToProcess "0" offset:[0,5]
Button Process "Start File Processing" enabled:false offset:[0,5]

-- following is executed when the utility is started
on LoadAndRenderAll open do
( sourceDir=undefined
files=#()
)

-- define the user interface handlers

on aboutProcessAll pressed do
messagebox "Load And Resave All\nv1.0\nby Larry Minton"

on SourcePath pressed do
( local tmp=getSavePath caption:"Specify Source Directory"
if tmp != undefined do
( sourceDir=tmp
if sourceDir[sourceDir.count] != "\\" do sourceDir += "\\"
SourcePath.text=sourceDir
if debug do (format "Source directory: %\n" sourceDir)
Process.enabled=true
files=collectFileNames sourceDir filesToProcess subdirs:doSubDirs.checked
stripBasePath sourceDir files
numFilesToProcess.text=files.count as string
)
)--End on SourcePath

on doSubDirs changed state do
( if sourceDir != undefined do
( files=collectFileNames sourceDir filesToProcess subdirs:doSubDirs.checked
stripBasePath sourceDir files
numFilesToProcess.text=files.count as string
)
)

on Process pressed do
( local theFile, status_ok
local num_failed=0
local num_converted=0
deletefile (sourceDir+"convert_file.log")
logfile=createfile (sourceDir+"convert_file.log")
if logfile == undefined do throw "Error creating log file in " sourceDir
progressStart "Processing progress"
progressUpdate 0
resetMaxFile #noPrompt
for fin in files do
(
-- rebuild the file name
theFile=sourceDir + fin
format "Processing file: %\n" theFile to:logfile
flush logfile
format "Processing file: %\n" theFile
try (status_ok=getTheFile theFile)
catch (status_ok=false)
if (getProgressCancel()) do exit
progressEnd ()
progressStart "Processing progress"
if not (progressUpdate (100*(num_failed+num_converted)/files.count)) do exit
if status_ok do status_ok=processTheScene theFile logfile
if status_ok == #cancel do exit
if not (progressUpdate (100*(num_failed+num_converted)/files.count)) do exit
if status_ok then
num_converted += 1
else
( format "Error processing file: %\n" theFile to:logfile
num_failed += 1
)
)
progressEnd ()
resetMaxFile #noPrompt
close logfile
gc()
messagebox ("Number of failures processing files: "+(num_failed as string)+
"\nNumber of successes processing files: "+(num_converted as string)+
"\nSee file "+(logfile as string)+" for processing log") title:"Processing Complete"
)--End on Process

)--End LoadAndRenderAll

if floater1 != undefined then (closeRolloutFloater floater1) -- If floater1 already open, then close.
floater1=newrolloutfloater "Load and resave all" 200 220
addrollout LoadAndSaveAll floater1

is that so hard?

Anubis · 2011-04-15

I remember some examples about goes with Max instalation.
But here you go a simplified script.

Attachments

ubikstudio · 2011-04-15

thanks but this script only import all 3d present in a folder

what i want is batch to load the *.3ds files and export it in the same directory with the same name *.max

ubikstudio · 2011-04-14

no one can help?:(