Skip to content

Instantly share code, notes, and snippets.

@MattOstgard
Last active November 15, 2021 05:54
Show Gist options
  • Save MattOstgard/31dd01530697c3ab9dea5fc8b7babc40 to your computer and use it in GitHub Desktop.
Save MattOstgard/31dd01530697c3ab9dea5fc8b7babc40 to your computer and use it in GitHub Desktop.
Create MaxScript .api file for use with the automcomplete feature of the MaxScript editor.
/***
Create MaxScript .api file for use with the automcomplete feature of the MaxScript editor.
Originally Created by:
James Haywood
http://apps.jhaywood.com/blog/
Updated by Matt Ostgard
***/
(
filteredSS = stringstream ""
ss = stringstream ""
apropos "" to:ss
seek ss 0
while not eof ss do
(
l = readLine ss
if matchPattern l pattern:"*#struct:*" then
(
n = (filterString l " ")[1]
l = readLine ss
while matchPattern l pattern:"*public,*" do
(
format "%.%\n" n (trimLeft (filterString l ":")[1] " ") to:filteredSS
l = readLine ss
)
)
else if matchPattern l pattern:"*(const *" then
(
format "%\n" (filterString l " ")[1] to:filteredSS
)
)
filePath = (getDir #maxRoot) + "maxscript.api"
if (doesFileExist filePath) then (
-- File exists so remove and create a fresh one
deleteFile filePath
)
fStream = createFile filePath
format "%" (filteredSS as string) to:fStream
close fStream
edit filePath
)
@MerlinEl
Copy link

MerlinEl commented Jan 2, 2019

Hi Matt, nice script :-)
I made some changes for Notepad++ as XML
[CODE]
fn generateNotepadApi = (

local all_commands = #()
all_commands += #("<?xml version=\"1.0\" encoding=\"Windows-1252\" ?>")
all_commands += #("<NotepadPlus>")
all_commands += #("\t<AutoComplete>")
all_commands += #("\t\t<Environment ignoreCase=\"yes\" startFunc=\"(\" stopFunc=\")\" paramSeparator=\".\" terminal=\";\" />")

local ss = stringstream ""
apropos "" to:ss
seek ss 0
while not eof ss do
(
	l = readLine ss

	if matchPattern l pattern:"*#struct:*" then
	(
		n = (filterString l " ")[1]
		l = readLine ss
		while matchPattern l pattern:"*public,*" do
		(
			local fu = (trimLeft (filterString l ":")[1] " ")
			all_commands += #("\t\t<KeyWord name=\""+ n +"."+ fu +"\" />")
			l = readLine ss
		)
	)
	else if matchPattern l pattern:"*(const *" then
	(
		local fu = (filterString l " ")[1]
		all_commands += #("\t\t<KeyWord name=\""+fu+"\" />")
	)
)
--close XML header
all_commands += #("\t</AutoComplete>")
all_commands += #("</NotepadPlus>")

for cmd in all_commands do format "%\n" cmd

)
generateNotepadApi()
[/CODE]
MerlinEl 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment