I just released the first stable version of the Maxscript Editor control plugin MXSEditor.

In short, it allows the Maxscript Editor to be controlled using maxscript and exposes the Editor’s internal SciTE API to maxscript. Addionally it lets you use the Maxscript Editor in an extended viewport and control several aspects of the Editor window. It allows for pretty advanced usage, but the extended viewport functionality might come handy for many casual scripters too

Its important to read the comprehensive documentation below and in the ZIP package to unleash the plugins possibilities
To make use of the maxscript exposure of the SciTE interface,  knowledge of the SciTE interal API is a plus. It’s important to read the accompanying documentation below, as well as the references to the SciTE online documentation.

FEATURES:

  • Maxscript Editor as Extended Viewport
  • Extensive control over the Maxscript Editor via maxscript
  • Access to the Scintilla/SciTE internal command set (see Scintilla Docs )
  • Callback mechanism to get notified about changes and events occuring in the maxscript editor

DOWNLOAD:

3ds Max MXSEditor Plugin


Detailed Documentation:

VERSION HISTORY:

Version V1.0, DC20160720

  • Updated to unicode compatibility,
  • Max 2008 to Max2017, x86 and x64 compatibility
  • Callback functionality implementation
  • Lots of other fixes and updates
  • Documentation added

Version V0.50 – Beta 1, DC20120214,

  • First public release

AUTHOR:

Josef Wienerroither aka “spacefrog”
Web: www.frogsinspace.at
Email: spacefrog@chello.at


DOWNLOAD & INSTALL:

The most recent version can be downloaded here: 3ds Max MXSEditor Plugin

Copy the appropiate file according to your 3ds Max version to your plugins folder and restart 3ds Max. The plugin should now be operational. To check this, type “showinterface MXSEditor” in the listener and hit enter. If a list of public properties and functions appears, the plugin got loaded.


USAGE:

Most of the functionality is of advanced usage and accessable via the maxscript interfaces. Features for more general maxscript usage are documented below. For detailed documentation about the Scintilla/SciTE related functionality, please refer to the official Scintilla Documentation.

IMPORTANT:

The Scintilla/SciTE version used for the 3ds Max maxscript editor is pretty outdated. Additionally it got heavily modified for the integration with 3ds Max. My investigation lead to the conclusion that it’s based on codebase version 1.71, which was released back in August 2006. You may visit Scintilla’s history page to read more about the progress made since then. 3ds Max 2008 was the first version which incorporated the new maxscript editor, thus this seems plausible.

This is important to remember when accessing Scintilla/SciTE related APIs when using this plugin. Many of today’s Scintilla/SciTE features and documentation DO NOT apply to the maxscript editor. Only ever expect the featureset and API of V1.71. As today’s online documentation targets the newer versions only, it’s recommended to use the docs bundled with the V1.71 distribution.


MXSEditor Interface:


Main maxscript interface to control the editor,
showinterface mxseditor” reveals all available methods and properties

Properties:


 

Property Description
x, y, width, height Maxscript editor window position and size (if not in extended viewport)
enableCallbacks quickly disable or enable installed callbacks without removing them
isVisible Toggle maxscript editor visibilty
verbose Toggle Scintilla commands verbose listener output
isExtendedVP Maxscript editor is currently in extended viewport (readonly)
mainWHND Maxscript editor‘s window handle
editHWND Maxscript editor edit component‘s window handle
documentCount Number of currently opened documents (tabs) in the maxscript editor
currentDocument Full path and filename of the currently active tab‘s document

 

Methods:


 

Redraw()
Redraw the text content of the current visible tab

 

Show()
Opens the Maxscript editor window ( see .isVisible property to hide )

 

<boolean> EndExtendedVP()
Detaches the maxscript editor from an extended viewport and restores the original editor window. Returns true if the editor was in an extended viewport, false otherwise.

ReloadOptions()
Reload Maxscript editor configuration files ( eg. after a setting got changed externally )

 

<boolean> EditFile <filename> quiet:<boolean>
Open file in editor, if quiet:true is passed as optional argument, the usual modal dialog prompt is suppressed in case the file does‘nt exists

 

<string> DocumentAtNumber <index>
Returns the full path of the file loaded in editor‘s tab # <index> ( 1 based )

 

<boolean> SetWindowPosition x y w h menuCommand
Set maxscript editor‘s position and size using only one call

 

MenuCommand <string>menuCode
Sends the passed SciTE menucode the maxscript editor to perform the corresponding SciTE action. For a quick list of available command codes, see ListMenucodes() below.
Note that the maxscript editor might not support all of those listed menucodes. For documentation of the SciTE menu codes, see the SciTE documentation here.
Examples:
mxseditor.menucommand "IDM_FULLSCREEN" --toggles fullscreen mode
mxseditor.menucommand "IDM_TABSIZE" --opens tabsize settings

 

<string> GetConfigProperty <name>

Returns the string based property <name> from the current editor configuration. Those properties get read from the various editor configuration files at 3ds Max startup ( eg. MXS_Editor.properties ). If the property does‘not exist, and empty string ( “” ) is returned.

Example:
GetConfigProperty “font.base“ returns the configured base font as string value

 

<int> GetConfigIntProperty <name>
Returns the property <name> from the current editor configuration as integer. If the property is not an integer a value of 0 is returned. If the property does‘not exist -1 is returned.

Example:
GetConfigIntProperty “caret.width” returns the cursor’s width in pixels

 

SetConfigProperty <string> <string>
Sets the property <name> from the current editor configuration to the passed string value. Please note that this is of limited use, as the new property value does not become active before 3ds Max is restarted. As the value does’nt get saved to the configuration file, it will be lost after a restart.

 

ListFunctions()
Lists all SciTE internal commands which can be used to control the maxscript editor component. See the documentation or the MXSEFuncs Interface below. For a description of the individual SciTE keycommands, see the official online documentation here and here.

Note that not all commands might be implemented or supported in the maxscript editor.

 

ListConstants()
Lists all SciTE internal constants and there corresponding integer value to be passed to the MXSFuncs and MXSProps interfaces. See the documentation for MXSEFuncs and MXSProps below. For a description of these constants see official Scintilla documentation here.

Note that not all constants might apply or be supported in the maxscript editor.

 

ListProperties()
Lists all SciTE internal properties and their signature available to query and change the current configuration and settings of the maxscript editor using the MXSProps interface. See the documentation for MXSProps below. For a description of those properties, see the official online documentation here. Note that not all properties might apply or be supported in the maxscript editor.

 

ListMenucodes()
Lists all available SciTE menu commands available which can be sent to the maxscript editor. See the documentation for the MenuCommand() method above. Note that the maxscript editor might not support all of those listed menu commands. For documentation of the SciTE menu commands, see the SciTE documentation here.

 


MXSEFuncs struct


Maxscript struct to access Scintilla’s editor functions. Entering “MXSEFuncs” in the listener reveals two public methods

Methods:


 

List()
Lists available SciTE internal editor commands and their parameter signature. For a description of the individual SciTE keycommands, see the official online documentation here and here.Note that not all commands might be implemented or supported in the maxscript editor.

 

Call()
Calls a SciTE internal editor keycommand. The first argument is the SciTE command name passed as string value. Addional arguments depend on the specific SciTE’s function signature. See MXSFuncs.List() below for the various command’s arguments and their data types. Command parameters and return values are past as their respective maxscript equivalents.

Example:
To set the editor selected text’s background color we use MXSFuncs.List()or the SciTE online documentation to find the command void SetSelBack(bool, color).

Thus we use MXSFuncs.call() to actually execute the command in the listener:
mxsefuncs.call "SetSelBack" true new (color 100 200 30 128)
(see http://www.scintilla.org/PaneAPI.html for a description of the boolean parameter…)

Maxscript variables can be passed by reference with commands that expect a variable to be filled with additional return data ( eg. the selected text)

Example:
To receive the currently selected text we use the following mxsefuncs call
mxsefuncs.call "GetSelText" &myText
The Maxscript variable myText now will contain the currently selected text


MXSEProps struct


Maxscript struct to access Scintilla’s editor properties. Entering “mxseprops” in the listener reveals thw following public methods

Methods:


 

List()
Similar to mxsefuncs.list(), this one lists available SciTE config properties. They essentially represent the current internal settings and state of the editor component. t’s important to recognize that those are NOT properties defined in the external scintilla “options” files . See the official online documentation here.Note that not all properties might be implemented or supported in the maxscript editor.

 

Get <propertynamestring> [<optional argument>]
Returns the current value of the corresponding property. See mxseprops.List() for available properties, their return datatypes and the optional argument

 

Set <propertynamestring> <value>
Sets the current property value. See mxseprops.List() for available propertynames and their value type ( the leftmost column of the output ).

Examples:
To change the current zoom level of the editor text ( default value is 0 )
mxseprops.set "zoom" 4

Or to select the current editor tab’s text from character position 10 to position 150
mxseprops.set "selectionstart" 10
mxseprops.set "selectionend" 150

 


MXSECallback struct


Maxscript struct to access the callback framework. Callbacks hook into maxscript editor notifications. This includes events like text and editor input focus changes, autocomplete selections, mouse input events etc…

Methods:


 

Enable(), Disable()
Enable/disable the callback notification functionality globally. Does not modify the list of registered callbacks, but provides a way to quickly enable and disable the whole callback mechanism.

Set <event id> <maxscript function>
Registers the corresponding maxscript function to be called when respective notification is triggered. For a list of valid event ids, please see the List() method’s documentation below.

 

Get <event id>
Get the maxscript function that is registered to be called by the the corresponding notification event.

 

List()
List all available and supported SciTE notification event ids.
Removes the given event id from the list of registered notification events. The corresponding maxscript function will no longer be called when the notification event occurs.

 

RemoveAll()
Removes all maxscript functions from the notification callbacks. Though the notification callback mechanism is essentially disabled, notification events are still processed internally. Should be followed by Disable() (see above ), to completely disable the notification callback mechanim.

 

Show()
List current installed SciTE notification callback Ids and their respective maxscript function.

 

GetCallbackData()
To be called inside a registered notification callback function. Returns an array holding 19 data elements which form a Scintilla SCNotification struct. For further documentation about this struct’s content and which fields hold valid data for a given callback, read the official documentation here. This includes exact documentation about which fields get used with which notification.

The elements in the array, their corresponding SCNotification struct counterparts and the event ids which use those fields to pass data. This might be not complete, so it’s always good to experiment and check for other eventId/valid field combos. It might be feasable to analyze the relevant SciTE source code ( SciteBase.cxx etc. ) to learn about addional callback data passing.

 

  1. idFrom: Integer, ControlID which sent the notification
  2. code: Integer, the raw SCN_* notification code ( see SCNotification struct documentation )
  3. position: Integer, character position value
    used with: #StyleNeeded, #DoubleClick, #Modified, #DwellStart, #DwellEnd, #CallTipClick, #HotSpotClick, #HotSpotDoubleClick
  4. ch: Integer, character entered, used with: #CharAdded
  5. modifiers: Integer, modifiers flags, used with: #HotSpotClick, #HotSpotDoubleClick
  6. modificationType: Integer, type of modification, used with: #Modified
  7. text: Integer64, memory ADDRESS of textbuffer or undefined
    for performance reasons, this field only holds the ADDRESS if there is actual text available with the notification or undefined otherwise. To retrieve the text, see GetCallbackText() below.
    Used with: #Modified, #UserListSelection, #AutoCompleteSelection
  8. length: Integer, length value used by certain notifications, used with: #Modified
  9. linesAdded: Integer, number of lines added , used with: #Modified
  10. message: Integer, message code, used with: #MacroRecord
  11. wParam: Integer, wParam for message, used with: #MacroRecord
  12. lParam: Integer, lParam for message, used with: #MacroRecord
  13. line: Integer, used with: #Modified, #DoubleClick
  14. foldLevelNow: Integer, current foldlevel applied to the line, used with: #Modified
  15. foldLevelPrev: Integer, previous foldlevel for the line, used with: #Modified
  16. margin: Integer, id of the margin that was clicked on, used with: #MarginClick
  17. listType: Integer, listtype picked , used w.: #UserListSelection, #AutoCompleteSelection
  18. x: Integer, horizontal pixel position , used with: #DwellStart, #DwellEnd
  19. y: Integer, vertical pixel position, used with: #DwellStart, #DwellEnd

 

 

GetCallbackText()
To be called inside a registered notification callback function. Retrieves and returns text passed by the current notification, if the notification supports that. Returns undefined in the other case.

MXSEditor V1.0 Final released…
Please share this:

6 thoughts on “MXSEditor V1.0 Final released…

  • Hello,
    I was wondering if you planned to release it for the newer version of 3ds max ?
    Thanks a lot for your work

  • Hi,
    thanks for great job with mxseditor. Is it possible to hook to SCI_KEY event?

  • I’ve got extended the viewport setup with the mxs editor and the listener and saved it as maxstart.max. It opens up fine but when max is reset then the display of the editor has not redrawn. Listener window seems fine.

    BTW, this is truly awesome. Do you know if it’s possible to have different colour background for commented out text like.
    /*
    This text has a different coloured background
    */

    1. Hey 3dwannap: i just checked this in Max 2014 , and for me refresh of the extended MXSEditor viewport after i reset or restart 3ds Max startup is fine. Which Max version do you see the refresh issue with ?

      For your second question regardingcomments background color:
      This actually does’nt really require the MXSEDitor plugin at all. You can simply make use of the “MXS_EditorUser.properties” file in the max root folder. In this configuration file, you can set SciTE/Maxscript editor options. As reference what options you can use and change , look inside the “MXS_Editor.properties” file. The settings in “MXS_EditorUser.properties” get priority.

      To change the background color of MXS comments, you have to set the following two options in “MXS_EditorUser.properties”:

      colour.code.comment.line=fore:#00FF00,back:#404040
      colour.code.comment.box=fore:#FF0000,back:#202020

      The first line will give you bright GREEN text on light grey background on line comments ( starting with — )
      The second line will give you a bright RED text on a not-so-light grey on block comments ( encapsulated in /* …. */ )
      To leave the text color on your default setting, simply leave out the “fore:#00FF00,” part

      I guess you will figure the rest out yourself

      BTW:
      For some nice dark MXS Editor coloring theme, you may want to use my DarkScintilla Color scheme available on scriptspot
      http://www.scriptspot.com/3ds-max/scripts/darkscintilla-maxscript-editor-dark-scheme
      This works exactly by making use of “MXS_EditorUser.properties” . You could change the comment background coloring in there after installation
      cheers, Josef

      1. Hi, thanks for the detailed response. That comment background thing is great as it easily allows me to differentiate between both types of comments.

        But is it possible for the background text of say:
        colour.code.comment.line=fore:#000000,back:#CFCFCF

        to only have that colour on the text and not the whole line after “–”

        Yes that bug is differently appearing. It’s max2016 SP3.

        Also there’s another bug whereby if you have a program on top (in focus), lets say firefox. And you click inside the extended viewport of the listener AND editor in there extended viewport state then max UI doesn’t take to the front. You have to click elsewhere for max to be in focus.

  • Thanks to Fusion Yuan for reporting a small bug with the extended viewport functionality:
    When the Maxscript editor is in a extended viewport, open Tabs can’t be closed closed using the File->Close or the RMB->Close menu. As i always simply use Ctrl-w to close the current window, i did’nt catch this. Will be fixed in the next update …

Comments are closed.