View Full Version : Get acces to macroscripts


JHN
02 February 2008, 02:23 PM
Is there anyway to get the properties of macroscripts in max?

I would like to build a menu with all macroscript from a certain categorie. Ideally I would check for a categorie and get the names.. that way I can build a menu easily. But I don't see no way to get acces to the macros?

There is "macros.list()" which will print all macros to the listener, I could get that text and search through it, but it seems slow... Is there anyway to search through the macroscripts without using brute force?

-Johan

PEN
02 February 2008, 03:47 PM
You can probably use that command but put it to a stringStream then read and parse it. still not ideal but should work. Parsing it will be the hassle as it isnt comma seperated but space seperated.

PEN
02 February 2008, 04:37 PM
Close...



macroStream="" as stringStream
macros.list to:macroStream

seek macroStream 0

num=1
clearListener()
while not eOf macroStream do
(
str=(readLine macroStream) as stringStream
while not eOf str do
(
itemStr=(readDelimitedString str "\"") as stringStream
itemStr=trimLeft itemStr " "
itemStr=trimRight itemStr " "
print itemStr
)
num+=1
if num>1 then exit
)

PEN
02 February 2008, 04:52 PM
I think that it is still missing some.


macroStream="" as stringStream
macros.list to:macroStream

struct macroSt (id,name,category,location)
macrosAr=#()

seek macroStream 0

num=1
clearListener()
while not eOf macroStream do
(
str=(readLine macroStream) as stringStream
ms=macroSt()
ms.id=item=trimRight (trimLeft ((readDelimitedString str "\"") as stringStream) " ") " "
ms.name=item=trimRight (trimLeft ((readDelimitedString str "\"") as stringStream) " ") " "
item=((readDelimitedString str "\"") as stringStream)
ms.category=item=trimRight (trimLeft ((readDelimitedString str "\"") as stringStream) " ") " "
item=((readDelimitedString str "\"")as stringStream)
item=((readDelimitedString str "\"")as stringStream)
item=((readDelimitedString str "\"")as stringStream)
ms.location=item=trimRight (trimLeft ((readDelimitedString str "\"") as stringStream) " ") " "
append macrosAr ms

-- num+=1
-- if num>1 then exit
)

print macrosAr

PEN
02 February 2008, 05:34 PM
I see where it is failing. I have macros where I called them "\"M\" Group"

If is causing a problem with the way I'm sorting the information.

JHN
02 February 2008, 07:26 PM
Funny thing I tried sort a similar approach but couldn't get the output of macros.list anywhere other than in the listener... I'll work on this! It should only run once on startup so maybe it's not a big performance hit...

Thanks for this! Hopefully some new functionality is added to the macros struct for accessing macroscripts.

-Johan

CGTalk Moderation
02 February 2008, 07:26 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.


1