Notifications
Clear all

[Closed] Launch script from commandline with arguements

Well… after punching my head with this I think we might be over complicating this… if you want to batch export, why just dont you do

3dsmax.exe importfile.max -U MAXScript "C:\exportfile.ms"

This way it opens the file and exports it…isnt that it? And I guess for importing it’s the same thing, actually there’s a good example in the backburner command line control.



Batch Export of Objects in a Series of MAX Files
Running the following batch file export all objects out of a series of 3ds Max files on a file server using 3ds Max and MAXScript.

The export.ms file:

exportFile (maxfilepath + maxfilename + ".obj") #noPrompt using: Wavefront_ObjectExporterPluginThe batch file:

rem begin batch filedir \\fileserver\maxfiles\*.max /s /b >c:\fileslist.txtc:cd "\Program Files\Autodesk\3ds Max 2010"cmdjob -jobname "batch export objects from max files" -manager managername -tasklist c:\filelist.txt 3dsmax.exe %%tp1 -U MAXScript \\fileserver\scripts\export.msrem end batch fileThe second line of the batch file (dir) writes out the list of files to fileslist.txt. (see image below) This text file is used as the tasklist. In the cmdjob line, the –taskname parameter has the value 1 which, means that each task will get its taskname from the first column of the taskfile. The %tp1 parameter specified after “3dsmax.exe” tells the cmdjob plugin to use task parameter 1 (column 1) from the tasklist as an argument to pass to 3dsmax.exe

OR you want to IMPORT an object and then EXPORT it, in the same Max session?

OK got it, I got it right in the first example, the problem was the \ and ” interpretation from cmd.exe, so here’s the supposed correct method:

3dsmax -mxs "global inputdir = @\"C:\\TEST_INPUT\";global outputdir = @\"C:\\TEST_OUTPUT\";filein \"C:\\batchexporter.ms\""

That being said, to have a ” or a \ inside the arguments you need ” and \

BTW Pete I’ve found this which might be useful for you: http://www.autohotkey.net/~deleyd/parameters/parameters.htm#WINCREATE

Cheers!

From what I’ve read so far it is impossible to change the process arguments after it has been started. Also it seems that it’s possible to instance the current running process but it always starts a new process thread (Dunno if this is correct as I have some trouble understanding the correct technical english, as it’s not my native language).

But I thought of something, why not use SendKeys or SendMessage to repeat tasks, or update stuff on the current 3dsmax process? I’m sure you guys thought of that before.

Thanks for the input Denis, Artur.

My earlier thoughts are really to do with the nature of passing data from an external program (or class) so the export part was just something i was mulling over as an example (I don’t actually need to export objects from max with the commandline!)

but like you both rightly said, I thought the complications were not worth automating simply opening max and running a script yourself. I just liked the notion of be able to build dotnet applications that were not parented to the max interface but could still pass data back and forth somehow. I’m assuming that the Maxscript editor does it this way somehow, as you don’t get the editor returned as a handle when you ask for all windows parented to max. So it must be doing something nifty to pass the script from the editor to evaluate in max.

If managedservices.dll could run outside of max I would think this would be a good place to start. however I get an error debugging this dll when referenced in Visual Studio so I’ve not managed (no pun intended) to get anywhere with that.

cheers all

Hey All,

thanks so much for all of your comments,

Here is what i am trying: unfortunately max starts and exits with no error message?!?!?

My goal is to be able to produce some .obj files in another program before doing an automated uvw unwrap then auto-producing some unity3d exe’s. I’ve got most of this working just having problems with max :*(

.\3dsmax.exe -mxs "global inputdir = 
@\"D:\\Coding\\3dsMax\\UnwrapUVW\\TestData\"; global outputdir = 
@\"D:\\maxTest\\max14\"; filein 
@\"D:\\Coding\\3dsMax\\UnwrapUVW\\commandlineunwrapper.ms\""

utility UnwrapAll "UnwrapAll"
(
-- FUNCTION DECLARATIONS
-- A function used to modify file names containing '\' to "\\"
fn replaceChar str oChar rChar = 
	(
		tStr = ""
		for i=1 to str.count do
		(
			if str[i] == oChar then tStr += rChar
			else tStr += str[i] 
		)
		tStr
	)
 
local dir = inputdir
if dir == undefined do return false
files = getFiles ( (replaceChar (dir as string) "\\" "[\\\\]( http://forums.cgsociety.org/ )") + "[\\*.obj](file://*.obj)" )
for f in files do (
	resetMaxFile #noPrompt
	importFile f #noPrompt
	max views redraw
	max modify mode
	select objects
	for i in selection do (
	   un = Unwrap_UVW ()
	   un.setApplyToWholeObject(true)
	   un.setIgnoreBackFaceCull(false)
	   addModifier i un
	   un.setTVSubObjectMode(3) --faces
	   un.setFlattenSpacing(0.002)
	   un.flattenMapNoParams()
	   --collapseStack i
	)
	destinationFile = outputdir + "\\" + getFilenameFile f + ".obj"
	exportfile (destinationFile)  #noPrompt
)
 

any ideas?

David

There you go dude, tested and working.

3dsmax.exe -mxs "global inputdir = @\"c:\
	ttobj\\objs\";global outputdir = @\"c:\	ttobj\\export\";filein @\"c:\	ttobj\
\commandlineunwrapper.ms\""
dir = inputdir
if dir != undefined then
(
	files = getFiles (inputdir + @"\*.obj")
	for f in files do 
	(
		resetMaxFile #noPrompt
		importFile f	#noPrompt
		max views redraw
		max modify mode
		for i in objects do 
		(
		   un = Unwrap_UVW ()
		   un.setApplyToWholeObject(true)
		   un.setIgnoreBackFaceCull(false)
		   addModifier i un
		   un.setTVSubObjectMode(3) --faces
		   un.setFlattenSpacing(0.002)
		   un.flattenMapNoParams()
		   --collapseStack i		
		)
		exportFile (outputdir +@"\" + (getFilenameFile f) + @".obj")	#noPrompt
	)
)

Kameleon vbmenu_register(“postmenu_7097770”, true); ,

That’s BRILLIANT

It’s working wonderfully!

I think part of my problem was running the script from powershell not plain cmd doh

Thank you

David

No problem, glad to help and learned something new

Page 2 / 2