|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Start New Max session in Max and open a specific file in that new max session
|
|
|
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,
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
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 (
n = 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?
|
|
|
|
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.
|
|
|
|
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.”
|
|
|
|
Great, works perfectly
Thanks!
Roger,
|
|
|
|
|
|