Posted By James Haywood

MaxScript Editor Autocomplete

You may or may not know about the autocomplete feature available in the MaxScript Editor (as of version 9 or so, I forget when it was changed exactly).  It's very helpful when scripting to cut down on typos and to speed things up over all (for another way to speed up script creation, check out Johan's blog post about using abbreviations).

To enable it, select "Open Global Options File" in the "Tools" menu.  Then do a search for "autocomplete" and change or insert the following lines...

autocompleteword.automatic=1
autocomplete.*.ignorecase=1
autocomplete.choose.single=0

You can see what each line actually does by reading the MaxScript help doc.  After you save the file, you'll see the autocomplete popup menu as you type when there is only one other word in the current script that mathces what you've typed up to that point.  Then just press Enter to fill out the rest of the word.  You can also press Ctrl-Enter at any time while you're typing to bring up a list of possible matches which you can then select from using the up/down arrow keys.

While that alone is pretty handy, wouldn't it be useful if autocomplete didn't just look for words within the current script, but was able to match against any MaxScript command too?  Well it can.  You just need to provide an api file for it to use which lists all of the commands.  Unfortunately, Autodesk doesn't provide one with Max, but I've made a script that will create one for you.

Download the script below and run it to create the api file.  It will try to save it to your Max root folder, but if you run into trouble becuase of Windows UAC settings, just modify the script to save it somewhere else, shut down Max, and then move it to the root.  Then add the following lines to the global options file...

autocomplete.*.start.characters=$(chars.alpha)$(chars.numeric)$_@#.
api.*.ms=maxscript.api

You can actually add more than one api file, for things like custom functions and such.  Just create a text file with one word on each line, or a word/period/word combination for functions within scructs, and save it to the Max root.  Then and add the file name to the above line following a semicolon, like so...

api.*.ms=maxscript.api;mytools.api

The one problem with using an api file is that it takes precedent over the current script, so that you no longer get words from the script you're working on in the autocomplete list.  What you can do, though, is if you're beginning to type the name of a local function or something that you know already exists in the current script, press Ctrl-Enter and you'll see your local word matches.

One last thing, I'm posting the script to create the api file instead of the api file itself because different versions of Max will have different commands available.  So this lets you create a new list for every new version of Max.

Download the script here.


 
14 Comment(s):
Alexander Berx said...
Dear my Haywood First of i would like to thank you for your great explenation on how to get intellisense in maxscript! I tried to download the script to create the api file, but it doesn't seem to be donwloadable anymore. Can you maybe provided a new download link for this? Kind regards Alexander
April 23, 2015 5:17 AM
 
Aeron said...
Hi James, Thank you for sharing this much needed feature! Please could you e-mail me/provide a link to your api script as the link is failing atm? Many thanks, Aeron
December 2, 2013 8:42 AM
 
Branko said...
Here is .net version ------------------------ fn createMxsAPI filePath:(getDir #maxRoot) showInEditor:on = ( local dnSW = dotNetClass "System.IO.StreamWriter" local dnFile = dotnetClass "System.IO.File" local mxsAPI = dotNetObject dnSW (dnFile.Create (filePath + @"\maxscript.api")) local filteredSS = stringstream "", ss = stringstream "" apropos "" to:ss ; seek ss 0 while not eof ss do ( theLine = readLine ss if matchPattern theLine pattern:"*#struct:*" then ( theWord = (filterString theLine " ")[1] ; theLine = readLine ss while matchPattern theLine pattern:"*public,*" do ( mxsAPI.WriteLine (theWord+"."+(trimLeft (filterString theLine ":")[1] " ")) theLine = readLine ss ) ) else if matchPattern theLine pattern:"*(const *" do (mxsAPI.WriteLine ((filterString theLine " ")[1])) ) mxsAPI.Close() ; mxsAPI.Dispose() if showInEditor do edit (filePath + @"\maxscript.api") ) createMxsAPI()
October 2, 2013 7:12 AM
 
dave said...
Thank you for posting this. I am just getting around to trying it out. One thing I have to change in your script was the line filePath = getDir #maxRoot + @"\maxscript.api" to filePath = getDir #maxRoot + "maxscript.api" Then it compiled great. Thanks!
April 18, 2013 1:04 PM
 
Priyabrata said...
Hey James, Thanks for the tutorial.I have tried creating the API file through your script. But it keeps throwing error that : "FileStream cannot create:C:\maxscript.api" The UAC settings are off in my Windows 8 machine and i am using 3dsmax 2013 64bit. Any suggestions?
April 12, 2013 5:47 AM
 
Cosmin said...
Great! you made me aware of a very useful feature
September 16, 2012 6:01 AM
 
akgandhi said...
hi can anybody tell about intellisense in maxscript.its an amazing feature but i think autodesk is missing it.
May 13, 2012 11:07 PM
 
Maxwell3D said...
Thanks for share is a very useful tool.
September 16, 2011 3:00 PM
 
Shawn Olson said...
Excellent, thanks! I'm curious as to why autocomplete isn't on by default... or why the editor doesn't just have a menu for it.
April 18, 2011 6:41 PM
 
br0t said...
Hey, I have had this site bookmarked since summer, but have only just today managed to finally try it out^^ That autocomplete thing is really great, thanks for sharing! Regards
January 13, 2011 10:19 AM
 
Sonia said...
Thanks!!! WONDERFUL tool!
December 7, 2010 8:29 PM
 
Noflame said...
very helpful tip. ~ thanks for share !!
July 13, 2010 10:27 PM
 
myanko said...
Wow, this is very nice. Thank you, it will help alot.
July 13, 2010 6:28 PM
 
Johan said...
Hi James, These settings you make in the global options file are not necessary. You should add them to the user properties as these settings override all other settings, so this keep your settings portable. I have given a talk on the EUE that included this specific topic, you can find the files on my blog: http://blog.subd.nl/2010/06/eue-sheets-and-samples/ Cheers, -Johan (JHN)
July 13, 2010 2:01 PM
 
Leave a Comment:
Name: * Email: *
Home Page URL:
Comment: *
   char left.

re-generate
Enter the text shown in the image on the left: *
 Remember Me?
* fields are requried
    


 
Google

User Profile
James Haywood
Seattle, WA

 
Category
 
Archives
 
Links
 
Visitors

You have 448274 hits.

 
Navigation