Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Start New Max session in Max and open a specific file in that new max session
  RSS 2.0 ATOM  

Start New Max session in Max and open a specific file in that new max session
Rate this thread
 
46754
 
Permlink of this thread  
avatar
  • rogero
  • Posted: 30 August 2010 10:54 PM
  • Total Posts: 18
  • Joined: 11 December 2007 06:37 PM

Hi,

I am working on a large project with many xref records. I want to make a script so that I can pick an object in the main scene, then a new max session opens with the file that the object comes from ( I now have the main scene open in one max session and one max session where the file with the selected part is present).

I tried this line: DOSCommand “C:\\Program Files\\Autodesk\\3ds Max 2010\\3dsmax.exe” but max didn’t start.

Thanks for any input.

Roger,



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

Ahhh - that old chestnut… ;)

It’s all about the quotes. You need to enclose the command itself within explicit quotes because doscommand strips off the outer level of quoting, which leaves the command as ‘c:\\program’ due to the spaces in the folder names.
Also, using a single forward slash instead of double-backslash is far less prone to error.

doscommand "\"C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe\""

Note the explicit quotes using the single \ as an escape character.



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 1
/img/forum/dark/default_avatar.png

Thanks for the reply, that was much better :-)

How do I get a specific file to be opened in the new session?
Roger,

Author: rogero

Replied: 31 August 2010 12:58 AM  
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

Pass the full pathname of the scene as a parameter. Same problem with quotes applies to that as to the executable.

doscommand "\"c:/3dsmax2010-64/3dsmax.exe\" \" c:/documents and settings/administrator/max9 projects/scenes/MultiSOMaterial.max\""

Note the space after the initial \” for the filename - without that the command will appear (to doscommand) as one long string and won’t work.

There are other command line options available besides a scene name. Look up Command Line in the Max help (not the maxscript help), and don’t confuse 3dsmax.exe with 3dsmaxcmd.exe.



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar
  • rogero
  • Posted: 31 August 2010 10:24 PM

Hi again

I can’t get this to work, I bet it it has something to do with quotes and slashes.
This is what I have:

-- Open an objects Xref file in a new Max session
(
 
1
 ObjToProcess
=getcurrentselection ()
 
XrefFileNameWithPath ObjToProcess[n].currentFileName
 XrefFileNameWithPathChanged 
substituteString XrefFileNameWithPath "\\" "/"
 
FileNameString "\"" + XrefFileNameWithPathChanged + "\\" +"\""
 
messagebox FileNameString
 doscommand 
"\"C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe\" \FileNameString"
)

--
C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe\
--doscommand "\"c:/3dsmax2010-64/3dsmax.exe\" \" c:/documents and settings/administrator/max9 projects/scenes/MultiSOMaterial.max\""

What is wrong here?



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

You don’t need (usually) to mess with strings returned by Max functions - they generally work “as is”.
It is to do with the quotes though I’ve not looked too closely at the code, just worked out how to do it by trial and error (and searching here because I knew I’d answered this (or a very similar one) before).

You could use either of the 2 methods to create the dosCmdStr - they are functionally equivalent - though the commented one is maybe easier to understand than the one with the explicit quotes.

(
Quote "\"" -- " comment only to stop the forum display getting confused
MaxPath 
= (getDir #maxroot) + "3dsmax.exe"
ObjToProcess selection[1]
XrefFileName 
ObjToProcess.currentFileName
--dosCmdStr Quote Quote MaxPath Quote " " Quote XrefFileName Quote Quote 
dosCmdStr 
"\"\"" MaxPath "\" \"" XrefFileName "\"\"" 
dosCommand dosCmdStr
)


Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar

Here are some tips/fixes to your code:
You need to wrap all strings in quotes. To add a quote around a string you need to use \” inside of the “”. You need to add all your strings together to make a single string. You must add all variables to your string outside of quotes, for example:

FileNameString "C:/some path/"+"someFile.max"
"\"
FileNameString\"" "FileNameString"
"\""+FileNameString+"
\"" "C:\some path\someFile.max"
doscommand+" \"C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe\" \""+FileNameString+"\""

Hope that helps you understand working with strings inside of maxscript,
-Eric



Eric Craft
“The Evil Monkey hiding in your closet.”

Replies: 0
avatar
  • rogero
  • Posted: 01 September 2010 10:15 PM

Great, works perfectly

Thanks!
Roger,



Replies: 0