it’s not safe in general case because MACRO can have specific for macroscript handlers which don’t make sense outside macroscript body (e.g. on isChecked, on isIndeterminate, on execute, on drop, etc.).
Run and Clean after that is the safer way IMHO
For example all my macros run with the execute handler which makes them ‘executable’ as a marcoscript only. (So you have to check first that the macro does not use execute handler before trying to run it your way)
Also some of my macros and tools need some other macros to be loaded (registered) before their own execution.
BTW
I believe that using MCR files is an outdated technique and rarely use it.
I usually define macro(s) inside a plugin or script (MS) file.
is it somehow related to tri-state of a macro button? I always thought it can only be on/off
isIndeterminate handler is usually used for menu and quad menu items. Because you can see it in UI (see the help).
You can use it in sense of ‘tri-state’ like as an ‘available’ action for not all currently selected (visible, etc.) nodes.
For example some action works for selected geometry class nodes. But current selection also includes helpers…
So you can define ability of this action as ‘indeterminate’ – means it works but not for all.
If there is no geometry nodes in the current list you should set it to ‘disabled’, if all nodes are geometries you should set it to ‘enabled’
Thanks for the explanation, Denis.
There’s not a single word in reference about this particular handler.
Can you please elaborate this?
Does Max treat MS and MCR different, ie, they are not just file extensions?
OK, I understand now and agree the idea I had can’t work.
Just drag-drop macroscripts into max to try them out will need more steps than that. I will need to know what category and what name the macroscript has. Then I need to track it down, before I can run it. Thankfully, I do have a little tool that quickly lists every macroscript there is, sorted by categories. Yet, it will require me to look into the macroscript, to figure out name and category.
So let me redesign my idea then
I drag drop the macroscript onto a “catcher” (that figures out the path of the file and then fileIn it for me) or I browse for the macroscript and press run, or equivalent method.
Then we’d need the maxscript to figure out the name and category that was just created.
Is that possible?
If so, then the next step could be simply presenting [macro name] [category] [run-button]
In case there are more macroscripts in the same file, they just get listed underneath each other
[macro name1] [category] [run-button]
[macro name2] [category] [run-button]
[macro name3] [category] [run-button]
What do you say?
With something like this you can all the registered MacroScripts. The last entry should the latest MacroScript you registered.
If you run it via MaxScript, then the MacroScript ID is returned and you could use it for tracking it.
(
stream = "" as stringstream
macros.list to:stream
seek stream 0
macroscrips = #()
while not eof stream do append macroscrips (readline stream)
lastentry = filterstring macroscrips[macroscrips.count] "\""
lastentry = for j in lastentry where j != " " collect trimleft (trimright j)
format "MacroScript:\n"
format "\t ID: %\n" lastentry[1]
format "\t Name: %\n" lastentry[2]
format "\t Category: %\n" lastentry[3]
format "\tInt. Category: %\n" lastentry[4]
format "\t FileName: %\n" lastentry[5]
format "\t Icon File: %\n" lastentry[6]
format "\t Icon Index: %\n" lastentry[7]
)
it’s not a correct split.
name, categories, and paths might have ” ” (space) too
MCR file expects only macros in it. MS file doesn’t have this expectation. But both of them will be just executed by the system
I tried this out just now.
When I put an MCR under $userMacros, they get loaded upon max start, or when I load them with macros.load().
Putting an MS file either under $userScripts or $userMacros don’t get loaded until I drag-drop them into max or load them somehow.
I was hoping that comments and stuff outside the macroscript would be left intact when I work with MS, but the effect was just the same.
So I dont really get the benefit. What am I doing wrong or what am I misunderstanding?