[Closed] Macroscripts? Can someone help me?
Hi i’ve created a Macroscript, so that i have a toolbar with buttons executing a script.
My macroscript is placed in the following folder…
Program Files\Autodesk\3ds Max 9\ui\macroscripts
In the macroscript i call a script, SCRIPT#1, that i made, placed in the following folder…
\Program Files\Autodesk\3ds Max 9\Scripts\Startup
It seems that i would always have to evaluate my SCRIPT#1 everytime i reboot Max so that my macroscript works properly
It’s my first time working with macroscripts so there’s obviously something i’m missing. Thanks for the help
nope – you have that pretty much right. Unless you can inline the code from ‘SCRIPT#1’ into the macroscript definition (directly or via an include), you’ll have to evaluate SCRIPT#1 before interacting with anything inside it.
Here’s one of the example.
– Creates Main Shape for Character
macroscript MainShape
category:“Longtail Studio Rigging”
buttontext: “Main Shape”
toolTip:“Creates the Main Shape Control”
(
on execute do
(
createMainShape() –that would be SCRIPT#1
)
)
-- Creates Main Shape for Character
macroscript MainShape
category:"Longtail Studio Rigging"
buttontext: "Main Shape"
toolTip:"Creates the Main Shape Control"
(
-- either stick all of the code from SCRIPT#1 here
on execute do
(
-- or include the file that has SCRIPT#1 here - e.g. via fileIn
createMainShape() --that would be SCRIPT#1
)
)
Either that, or have SCRIPT#1 run on startup…
- place SCRIPT#1 in the scripts\Startup\ folder
OR - place SCRIPT#1 in any of the plugin paths or subfolders of those paths.
Edit: Looks like you posted while I posted this – yes, it is slightly annoying… but at least that bit makes sense. Macroscripts being copied about… makes a little less sense and is a tad more annoying… but that’s another story
use filein to execute your script this way you dont have to update the macro definition every time, unless you change the script name !
[CODE – Creates Main Shape for Character
macroscript MainShape
category:“Longtail Studio Rigging”
buttontext: “Main Shape”
toolTip:“Creates the Main Shape Control”
(
– either stick all of the code from SCRIPT#1 here
on execute do
(
– or include the file that has SCRIPT#1 here – e.g. via fileIn
filein (getdir #scripts +”\startup\scriptname.ms”)
createMainShape() –that would be SCRIPT#1
)
)]
by the way, user macro are stored in :
Documents and Settings\Administrator\Local Settings\Application Data\Autodesk\3dsmax\2009 - 32bit\enu\UI\usermacros
martin
In that case, this might even be easier:
filein ("$scripts\\startup\\scriptname.ms")
Be aware though, fileIn executes the code in the global scope, not in the macroscript scope, so that means you’ll have to set global variables to access whatever function you need to access! This has gotten me a while ago to. “include <file>” injects the code right there where you place the statement, so you can acces it directly. “fileIn <file>” runs the script in a global scope, so to get access through it’s content you either need to set global vars in the fileIn’ed file or don’t use braces in that file, meaning all vars and functions will be made global right there (not a great solution!). fileIn is like, “run script”, include is like “I need to run that code in this place”.
-Johan
Thanks guys, i really appreciate all the help i’ve been given these past two weeks. Maxscript Reference helps to, but it never beats having somebody explaining it in normal syntaxe
Have a good day all
I’m I right to say that include is slower than putting the actual code since it have to read from disk ?
Depending on the speed of your disk I’d say yes, but how much including and fileIn’ing will you be doing… I think it’s neglectable speed wise, if your looping 10.000 times you’ll need to consider speed optimizations, including of fileIn’ing a file once should be dictated by the “program flow” ease of use, imo!
-Johan