Batch import .jt and save as .max

Hi guys,

maybe anyone could help me out with a simple script?

It should do batch operations:
Look into each subfolder of a mainfolder for a file with always the same name xyz.jt, import it in my 3ds max 2016 and save it in the same spot with the same name as the original .jt file, just as .max.

I came across a similar one, but more than 10 years old:
http://www.scriptspot.com/3ds-max/scripts/iges-batch-importer

I guess it is doing more or less what I want, just to .iges instead of .jt. Since I have no idea how to modify it to suit my needs, maybe somebody can show me how to do it?

Any help is very much appreciated!!!
Thanks alot in advance!!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

I don't know if this will works, because I don't have jt file, but try it:

------------------------------------------------------------------------------------------
-- IgesBatchImporter.ms
-- Copyright ©2000, Discreet
-- By Simon Feltman, [email protected]
[email protected]-------------------------
global igesInputPath = "C:\\3dsmax\\jt\\"
global igesOutputLog = "C:\\3dsmax\\jt\\igeslog.csv"
global igesRecursive = true
global igesRandomize = true
global igesSaveMaxFile = true
global igesCountSurfs  = true
 
------------------------------------------------------------------------------------------
rollout igesBatchRollout "jt Batch Importer"
(
	Group "Input Path"
	(
		EditText ed_path width:136 height:20 align:#left offset:[-6,0] text:igesInputPath
		Button  btn_path "..." width:16 height:17 \
			pos:[ed_path.pos.x+136, ed_path.pos.y] \
			tooltip:"Browse input path..."
	)
 
	Group "Output Log"
	(
		EditText ed_log width:136 height:20 align:#left offset:[-6,0] text:igesOutputLog
		Button  btn_log "..." width:16 height:17 \
			pos:[ed_log.pos.x+136, ed_log.pos.y] \
			tooltip:"Save log file..."
	)
 
	Group "Options"
	(
		CheckBox  chk_recursive	"Recurse sub-directories" align:#left offset:[-1,0] checked:igesRecursive
		CheckBox  chk_randomize "Randomize import order" align:#left offset:[-1,0]  checked:igesRandomize
		CheckBox  chk_saveMaxFile "Save MAX file" align:#left offset:[-1,0]         checked:igesSaveMaxFile
		CheckBox  chk_countSurfs "Count Surfaces" align:#left offset:[-1,0]         checked:igesCountSurfs
	)
 
	Button btn_doBatchImport "Do Batch Import" width:164
 
	------------------------------------------------------------------------------------------
	function LogOut text =
	(
		local ostream = undefined
		if ed_log.text != undefined and ed_log.text != "" then
			ostream = OpenFile ed_log.text mode:"a"
 
		if ostream != undefined then
		(
			format text to:ostream
			close ostream
		)
		else format text
	)
 
	------------------------------------------------------------------------------------------
	function DoImport inpath =
	(
		local exts = #("*.jt", "*.jt")
		local files = #()
 
		if inpath[inpath.count] != "\\" then
			inpath += "\\"
		format "%\n" inpath
 
		-- Get a listing of files into array 'files'
		for e in exts do
			Join files (GetFiles(inpath + e))
 
		-- Randomize the file listing if specified
		if chk_randomize.checked then
		(
			for i = 1 to files.count do
			(
				local j = Random 1 files.count
				local tmpstr = files[i]
				files[i] = files[j]
				files[j] = tmpstr
			)
		)
 
		-- Go through each file and import it
		for f in files do
		(
			local startTime = TimeStamp()
			LogOut ("\"" + f + "\",")
 
			try
			(
				ImportFile f #noprompt
				RedrawViews()
				LogOut "Succeeded,"
 
				if chk_saveMaxFile.checked then
				(
					f = (GetFilenamePath f) + (GetFilenameFile f) + ".max"
					SaveMaxFile f
					LogOut "Succeeded,"
				)
				else LogOut "N/A,"
 
				-- count surfaces
				local numSurfs = "N/A"
				if chk_countSurfs.checked then
				(
					numSurfs = 0
					for obj in objects do
					(
						if (classOf obj) == NURBSSurf then
							numSurfs += obj.surfaces.count
						else if (classOf obj) == SplineShape then
							numSurfs += obj.numsplines
						else if (classOf obj) == NURBSCurveShape then
							numSurfs += obj.curves.count
					)
				)
				LogOut ((numSurfs as string) + ",")
 
				local stime = (TimeStamp()-startTime) / 1000.0
				LogOut ((stime as string) + "\n")
 
				ResetMaxFile #noPrompt
			)
			catch
			(
				LogOut "Failed\n"
			)
		)
 
		if chk_recursive.checked then
		(
			for d in GetDirectories (inpath + "*") do
			(
				if not (DoImport d) then
					return false
			)
		)
 
		return true
	)
 
	------------------------------------------------------------------------------------------
	on igesBatchRollout open do
	(
		try   ( FileIn ((GetDir #plugcfg) + "\\jtBatchImporter.txt") )
		catch ( Format "jtBatchImporter.txt does not exist, will be created.\n" )
 
		ed_path.text = igesInputPath
		ed_log.text = igesOutputLog
		chk_recursive.checked = igesRecursive
		chk_randomize.checked = igesRandomize
		chk_saveMaxFile.checked = igesSaveMaxFile
		chk_countSurfs.checked  = igesCountSurfs
	)
 
	------------------------------------------------------------------------------------------
	on igesBatchRollout close do
	(
		ostream = CreateFile ((GetDir #plugcfg) + "\\jtBatchImporter.txt")
 
		Format "igesInputPath = \"%\"\n" ed_path.text to:ostream
		Format "igesOutputLog = \"%\"\n" ed_log.text to:ostream
		Format "igesRecursive = %\n" chk_recursive.checked to:ostream
		Format "igesRandomize = %\n" chk_randomize.checked to:ostream
		Format "igesSaveMaxFile = %\n" chk_saveMaxFile.checked to:ostream
		Format "igesCountSurfs  = %\n" chk_countSurfs.checked to:ostream
		Close ostream
	)
 
	------------------------------------------------------------------------------------------
	on btn_path pressed do
	(
		local path = GetSavePath caption:"Choose jt Import Directory"
		if path != undefined then
			ed_path.text = path
	)
 
	------------------------------------------------------------------------------------------
	on btn_log pressed do
	(
		local logpath = GetSaveFileName filename:ed_log.text caption:"Choose Log File"      \
			types:"Excel Text Files (*.csv)|*.csv|Text Files (*.txt)|*.txt|Log Files (*.log)|*.log|All Files (*.*)|*.*|"
 
		if logpath != undefined then
			ed_log.text = logpath
	)
 
	------------------------------------------------------------------------------------------
	on btn_doBatchImport pressed do
	(
		if ed_log.text != undefined and ed_log.text != "" then
		(
			local ostream = CreateFile ed_log.text
			Close ostream
		)
 
		LogOut "File Name,Import Status,Save Status,Surface Count,Time Elapsed\n\n"
		DoImport ed_path.text
	)
)
 
------------------------------------------------------------------------------------------
-- MacroScript IgesBatchImporter category:"Tools" tooltip:"jt Batch Importer"
-- (
 	igesBatchFloater =  NewRolloutFloater "jt Batch Importer" 200 294
	AddRollout igesBatchRollout igesBatchFloater
-- )

ALso, you can try this script, that I wrote to batch save OBJ as MAX file, but now it have to works with jt files:

--******************************************************************************************************
-- Created: 		23-06-2015
-- Last Updated:	17-11-2015
-- Version:			1.10
--
-- Author :  Kostadin Kotev / [email protected] / http://miauumaxscript.blogspot.com/
-- Version:  3ds max 2010 and up
--
-- Discription: Batch save selected JT files as .max files.
-- Usage: RUN IT
--
-- Wishlist:
--
--******************************************************************************************************
-- MODIFY THIS AT YOUR OWN RISK
 
 
macroscript miauuBatchSaveObjAsMax
category:"miauu"
tooltip:"Batch Save JT As Max"
buttonText:"Batch Save JT As Max"
(
	global rol_miauuBatchSaveObjToMax
    try(destroyDialog rol_miauuBatchSaveObjToMax)catch()
    rollout rol_miauuBatchSaveObjToMax "miauu's Batch Save JT As Max"
    (
		local ConvertClass = dotnetclass "system.convert"
		local ImageClass = dotnetclass "system.drawing.image"
		local logoIcon = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAJcEhZcwAACxIAAAsSAdLdfvwAAALcSURBVDhPbZJLSFRhGIa/1C6IMmmQFNownplzv8y5zIzOqGPimE5hFxfeZxQzu0AXDbtsXHWBwNpWaIt2lQWBFSS0qCholbsW7QwiiKBNRDlv//xTWtjiO9+B77zP+37/+QkA7QxXULu7mZLmVmq1K2lvtIzSjm/A0Wt/NjdEl0d62w+eGe2gyUyCTvXHaawnSRNDTVy7AuhwfdTt+Kg1XBFIWNVLmqZj/ryGc90yVN1CZ3vjx9PDLWpS3UJH+pI0nv0L0MaEaa+cYnr1M0OVIKkWNN0AXsQxe0KCIkvwCxI818bgvsTL8eFWmhpLrgLq9Korri4si4oJVTNg6Covy5RhGQrrOusqQqIEQVSQqI/mjvY1T68AhJCc0wwLuqbwmuwKAfdcDkl4MvAmjr1NEgNpMA0NghCEFXZzKwBRFHP54WhawudbNpbuePg+5+DVBR3vZlxgIYrFqwY+zNjoSckcbNvhVYAkhnIWI4/36czZRiNzzX/07kYYl7MSd812qsC8h96UxFOy81gLOLSHxX3ooi4scsBb5jrVL3PAGJt9u2uju7Wwpuc6awEne1mChRganALgy/0oprMiB5wdsXiCgV1yAeD8B3B8P0vwOIJUfWGFL7ct3DymcsDxLgV45GEo/SfBXyvIssQPcWKQ/XsGaP8NeP+gHtdGFA6YHLOBJxFkdv1nhUBtMOc4Nhflh/lusuKdifPp8j1fYWaksJtpOLFVgFNbOltd44fCLpFpsdiHJbZvhAPa6tj763pkUiJ000JIjzATGW12xfMVQIuygbZv2bhJ2uFbDAYFXDrh4dP1MAMoSCU14GkMnc0Wu+Immqyqz/2xdXXDsYKWPxqkUvJvKyM3UEJ6TUlc8ld+9QsqNNNmrg4ExUHEqPlxwF1/6nAD0WgjUU+0+F9ATVU5WYFSigY3kreDKOIvuaiGqpdNNYTdbtncSJzoYIIoGy+mTLyIAYqYFvQLPey9qVeXvysAAAAASUVORK5CYII="
		local curMaxVersion = ((maxVersion())[1] / 1000)
		local openFileRoll = dotNetObject "System.Windows.Forms.OpenFileDialog"	
        local disableForeColor = (dotNetClass "System.Drawing.Color").white
        local maxFiles = #()         
 
        dotNetControl lv_Batch "system.windows.forms.listView" height:200 width:273 pos:[10,10]
 
		button btn_getDir "Get Directory" width:108 pos:[290,10] tooltip:"Select all .max files in the given folder and/or its sub-folders"
        button btn_getFile "Get file(s)" width:108 pos:[290,35] tooltip:"Select one or multiple files in given folder"
        button btn_Clear "Clear" width:108 pos:[290,60]  
		radiobuttons rb_saveAs "Save As:" pos:[290,85]  labels:#("2010", "2011", "2012", "2013", "2014", "2015", "2016") default:1 columns:1 
 
		checkbox chkBox_showFullPath "Show Full Path" pos:[10,215]
		label lbl_select "Select:" pos:[120,215]
		button btn_all "All" pos:[157,214] width:40 height:18
		button btn_none "None" pos:[200,214] width:40 height:18
        button btn_invert "Invert"	 pos:[243,214]	width:40 height:18
		button bnt_saveAsPrevious "Save JT As Max" width:275 height:30 pos:[10,235]
		hyperLink http_miauu "miauu's MaxScripts" address:"http://miauumaxscript.blogspot.com/" pos:[300,270] color:(color 7 231 251)
		progressBar pb_xRefprogress value:0 color:green width:275 pos:[10,270]
 
		--	Credist to Peter Addington - http://lonerobot.net/?p=314
		function String2Bmp string =
		(
			local clipboardClass = dotNetClass "System.Windows.Forms.Clipboard"
			local ConvertClass = dotnetclass "system.convert"
			local imageclass = dotNetclass "System.Drawing.image"
			local bytearr = convertclass.FromBase64String string
			local memstream = dotnetobject "System.IO.MemoryStream" bytearr
			local DecodedImg = ImageClass.fromstream memstream
			memstream.close()
			DecodedImg
		)
		--	credits to Denis Trofimiv - http://forums.cgsociety.org/showpost.php?p=7708817&postcount=21
		function LoadMyLogoAsTitlebarIcon =
		(
			d = (windows.getChildHWND 0 rol_miauuBatchSaveObjToMax.title)[1]
			WM_SETICON = 0x0080
			ICON_SMALL = 0
			bm = dotnetobject "System.Drawing.Bitmap" (String2Bmp logoIcon)			
			ptr = bm.GetHicon()
			icon = (dotnetclass "System.Drawing.Icon").FromHandle (dotnetobject "IntPtr" ptr)			
			windows.SendMessage d WM_SETICON ICON_SMALL icon.handle
		)
 
        function AddColumns theLv columnsAr=
        (
            if chkBox_showFullPath.state == false then
                w=(theLv.width)-6
            else
                w=(theLv.width)+400
            for x in columnsAr do
            (
                theLv.columns.add x w
            )
        )
        function PopulateListView theLv=
        (
            rows=#()
            for x=1 to maxFiles.count do
            (
                if chkBox_showFullPath.state == false then
                    mapName = (getFilenameFile maxFiles[x])
                else
                    mapName = maxFiles[x]
 
                li = dotNetObject "System.Windows.Forms.ListViewItem" mapName
                append rows li
            )
            theLv.items.addRange rows
        )
        function InitListView theLv=
        (            
            theLv.clear()
			theLv.headerStyle = theLv.headerStyle.none
            theLv.view = (dotNetClass "system.windows.forms.view").details
            theLv.FullRowSelect = true    
            theLv.MultiSelect = true    
            theLv.checkBoxes = true                
            theLv.backcolor = (dotNetClass "System.Drawing.Color").DimGray
            theLv.forecolor = (dotNetClass "System.Drawing.Color").lightGray
        )
        function BatchListViewReIinit =
        (
            InitListView lv_Batch
            AddColumns lv_Batch #("")    
            PopulateListView lv_Batch
        )
        function TurnBatchLVchkBoxOn =
        (
            for i = 0 to lv_Batch.Items.count-1 do
                lv_Batch.Items.Item[i].checked = true
            lv_Batch.forecolor = disableForeColor
        )    
        function OpenFolders folderToOpen =
        (
            local checkFolderName = substring folderToOpen 1 (folderToOpen.count-1)
            if (symbolicPaths.isPathName checkFolderName) then
            (
                folderToOpen = symbolicPaths.getPathValue checkFolderName
            )                
            shellLaunch "explorer.exe" folderToOpen
        )        
 
        function GetFilesRecursive root pattern =
        (        
            dir_array = GetDirectories (root+"\*")
            for d in dir_array do
                join dir_array (GetDirectories (d+"*"))    
 
            my_files = #()                
            for f in dir_array do
                join my_files (getFiles (f + pattern))
 
            my_files
        )
 
        on btn_getDir pressed do
        (
            dir = getSavePath caption:"Select the directory" initialDir:"$scenes"
            if dir != undefined do
            (
                maxFiles = #()
                --    get all max files
                maxFiles = getFiles (dir+"\*.jt")
                --    check for subfolders
                subFiles = GetFilesRecursive dir "*.jt"
                if subFiles.count != 0 then
                (
                    msg = "The selected folder have subfolders!\n"
                    msg += "Do you want to include the files from the subfolders too?"
                    if queryBox  msg title:"Sub-folders found" do
                        join maxFiles subFiles
                )
				makeUniqueArray maxFiles
                PopulateListView lv_Batch
                TurnBatchLVchkBoxOn()
            )
        )
 
        on btn_getFile pressed do
        (
			result = openFileRoll.showDialog()
			result.ToString() 
			if (result.Equals result.OK) do 
			(
				filePath = (openFileRoll.fileNames)
				join maxFiles filePath
				makeUniqueArray maxFiles
                BatchListViewReIinit()
                TurnBatchLVchkBoxOn()
			)
        )
 
		on btn_all pressed do
		(
			for i = 0 to lv_Batch.Items.count-1 do lv_Batch.Items.Item[i].checked = true
		)
 
		on btn_none pressed do
		(
			for i = 0 to lv_Batch.Items.count-1 do lv_Batch.Items.Item[i].checked = false
		)
 
		on btn_invert pressed do
		(
			for i = 0 to lv_Batch.Items.count-1 do lv_Batch.Items.Item[i].checked = not lv_Batch.Items.Item[i].checked
		)
 
        on btn_Clear pressed do
        (
            maxFiles = #()
            BatchListViewReIinit()
        )
 
        on lv_Batch MouseDown arg do
        (
            --    delete selected max file from the listview
            if arg.button==arg.button.middle then
            (                
                if (hitNode = lv_Batch.GetItemAt arg.x arg.y) != undefined do
                (
                    deleteItem maxFiles (hitNode.index+1)
                    BatchListViewReIinit()
                )                
            )
            --    open folder of selected max file
            if arg.button==arg.button.right then
            (                
                if (hitNode = lv_Batch.GetItemAt arg.x arg.y) != undefined do
                (
                    f = (hitNode.index+1)
                    folderToOpen = (getFilenamePath maxFiles[f])
                    OpenFolders folderToOpen
                )                
            )
        )
 
        on chkBox_showFullPath changed state do
        (
			cbState = for i = 0 to lv_Batch.Items.count-1 collect lv_Batch.Items.Item[i].checked
            BatchListViewReIinit()
            for i = 0 to lv_Batch.Items.count-1 do lv_Batch.Items.Item[i].checked = cbState[i + 1]
        )    
 
		on bnt_saveAsPrevious pressed do
		(	
			local xRefCnt = (lv_Batch.Items.count - 1)
			local versionIndex = case rb_saveAs.state of
			(
				1: 2010
				2: 2011
				3: 2012
				4: 2013
				5: 2014
				6: 2015
				7: 2016
			)
			setWaitCursor()
			suspendEditing()
			resetMaxFile #noPrompt
			for i = 0 to xRefCnt where (lv_Batch.Items.Item[i].checked == true) do with redraw off
			(
				importFile maxFiles[i+1] #noPrompt
				filePath = getFilenamePath maxFiles[i+1]
				fileName = (getFilenameFile maxFiles[i+1]) + "_" + (versionIndex as string)
				newName = filePath + "\\" + fileName + ".max"
				if versionIndex == 2016 then
					saveMaxFile newName useNewFile:true quiet:true
				else
					saveMaxFile newName saveAsVersion:versionIndex useNewFile:true quiet:true
				resetMaxFile #noPrompt
				pb_xRefprogress.value = 100.0 * i / xRefCnt
				if curMaxVersion > 12 do
					windows.processPostedMessages()
			)
			completeRedraw()
			resumeEditing()
			setArrowCursor()
		)
 
        on rol_miauuBatchSaveObjToMax open do
        ( 
			try(LoadMyLogoAsTitlebarIcon())catch()
 
			openFileRoll.title = "Select Files"
			openFileRoll.Multiselect = true
			openFileRoll.Filter = "jt (*.jt)|*.jt"
			openFileRoll.FilterIndex = 1
			openFileRoll.RestoreDirectory = true	
 
            InitListView lv_Batch
            AddColumns lv_Batch #("Files")
        )
    )
    createdialog rol_miauuBatchSaveObjToMax width:405 
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.