I wonder if you can add scripted custom menus to eg MaxScript editor. Other UIs like the Material / Slate Editor are accessable from Customize User Interface > Menus.
The purpose would be the exact same; to add shortcuts to macroscripts that are related to that particular part of the interface.
Talking of the Maxscript editor.
If you make a selection of something inside the maxscript editor, can maxscript read what you have selected?
Are you sure about Slate ?
Even in 2020 none of its UI are accessible through Customize. (But I’m not sure about the last update 2020.3)
I had to find toolbar handle myself to add a button there
like this:
...
toolbar_hwnd = if toolbar_hwnd == undefined then GetSMEMainToolbarHWND() else toolbar_hwnd
local toolbar = gi.GetICustToolbar (ToIntPtr toolbar_hwnd)
if not ( ButtonExists toolbar_hwnd btnText ) then
(
local mbdata = gi.macrobuttondata.create macro_settings_ID "" "DropToSlate Settings" 0 "DropToSlate"
local toolMacroItem = gi.toolmacroitem.create 24 24 mbdata 31
toolbar.AddTool toolMacroItem toolbar.NumItems
...
.
You can easily append menu item using User32.AppendMenu, but then you’ll have to process all menu messages yourself. I had to write c# lib for that purpose.
nope, I was wrong. Seeing there were menu items for Material Editor made me assume that the same was for Slate.
Unfortunately, my knowledges in MXS are rather low, not to mention c#.
Could you please elaborate this? The c# lib-part, does it mean a plugin or is it still inside the MXS-environment?
Can you provide something that someone like me could adjust for their own need, ie putting menu items that run given macroscripts?
Wow, this is really cool! Love it when it simply works Now that you have sorted this out, I’ll post a new question dedicated for this particular matter.
I’ll check out that link as well.
doc = GetMXSEditorWindowText hwnd print out the whole text from the Macroscript Editor.
Instead of writing substring doc (start+1) (end - start), I wrote substring (GetMXSEditorWindowText hwnd) (start+1) (end - start)
Any comments on that?
About adding menu to the Maxscript Editor. This is still very complex for me. I am trying to understand the part that pinpoints the Maxscript Editor. I hoped to undertand that so that I would try it out on other places, eg Slate or anywhere else that doesn’t allow native menus…
As for the menu making itself.
So menuman.createMenu and menuman.createSubmenuItem isn’t what you use in this case?
Not in this case. In order to append anything to menu you first need to find one and it’s not possible. Otherwise we would see these menus in Customize…
if you don’t want locals printed in listener just wrap whole expression with braces and only the last one will be printed
open folder (based on above, but that opens eg getdir #userScript)
Some maxscript-related scripts, eg “Open Script” in Renaming menu items, Create Macroscript-tool (I have a macroscript for that) and so on.
your idea, Quick Executing code sounds promising too, so if you have a bunch of code you’d like to share with the community, they could also be part of that.
to summarize: a way to supercharge MXS Editor. Or any other UI that lacks of some buttons/menus they could have.
I know that I can have those tools in the toolbar or a menu in the main UI. But I think offering the user to add menus in where they want can be time saving and UI-friendly
Back to the scripts you provided. Could you please provide us some tutorial? Honestly, it’s rather complex code, since its a complex task.
Or a “front end” / customization part at the beginning of the script that lets you type in the relevant UX stuff, , followed by a -- Do not alter below this line where the “backend” part is. We, the non-skilled users, can simply ignore that part.
I would rather suggest you to use VSCode and completely forget about the editor build in max if you really need extended editor functionality. You’ve chosen a tough task to begin with.
.
As of tutorial just scroll down to the bottom of the source code. Two hotkey examples are provided. There’s nothing complicated even for a beginner level scripter.
But don’t expect too much of the code that I posted above. It needs testing, debugging etc…
.
I doubt it will ever happen to slate or mxseditor.
+1 to that. On top of being a much better editor it has the benefit that, being a separate application, if Max crashes you don’t lose your unsaved script changes. (not that it ever happens to me )