Linking intrinsically to Maya
Starting at launch
The execution of customized scripts when Maya starts can be easily achieved with the file userSetup.py in the folder Maya/scripts in your Documents, if the file doesn't exist, create it.
We will copy our awesome script in a new file named syntax.py in this folder, then we need to edit our userSetup.py file to add the following line ;
import syntax
Alrigh, then if you open your scriptEditor, and type
syntax.wrap()
our Command History QTextEdit will take some some colours !
A bit of hacking =) !
Now we have our function which colorize the Command History of Maya, we need to link it to Maya so each time the scriptEditor opens, the QSyntaxHighlighter will be parented to the corresponding QTextEdit ! Because everytime the window is closed, the Command History QTextEdit widget is deleted, so is our QSyntaxHighlighter !
If we turn on the option "Echo All Commands" in the scriptEditor we'll see that the command scriptEditor; is called when opening the window. After a search in Window → Settings/Preferences → Hotkey Editor under the Window section we find that the executed script for this function is ;
if (`scriptedPanel -q -exists scriptEditorPanel1`) { scriptedPanel -e -to scriptEditorPanel1; showWindow scriptEditorPanel1Window; selectCurrentExecuterControl; }else { CommandWindow; }
Unfortunately these 'inside' functions in Maya aren't editable, and even if they were, this will only change the script for the keyboard shortcut, not the other ways to open the window, like the little button for instance, will continue to execute the function quoted above.
So we're going to have a look on the internal Maya files, with the secret hope to find this function in some .mel script, using a software like Notepad ++ we will be able to search inside all Maya's files and find the one which contains our command.
A little - and efficient - search indicates that the file defaultRunTimeCommands.mel in the folder scripts/startup inside the Maya folder contains what we are looking for.
The file is really huge, and the line we want differs between Maya versions, for Maya 2013 that line is the 4096th, for Maya 2014 that's the 4228th, simply search scriptEditor; in the file should bring you to correct line =) !
We just need to add a simple MEL command at the end of the Maya command, from ;
-command ("if (`scriptedPanel -q -exists scriptEditorPanel1`) { scriptedPanel -e -to scriptEditorPanel1; showWindow scriptEditorPanel1Window; selectCurrentExecuterControl; }else { CommandWindow; }")
to
-command ("if (`scriptedPanel -q -exists scriptEditorPanel1`) { scriptedPanel -e -to scriptEditorPanel1; showWindow scriptEditorPanel1Window; selectCurrentExecuterControl; python(\"StdOut = syntax.wrap()\"); }else { CommandWindow; }")
So our color syntax will be called everytime scriptEditor; is executed, whatever how the command is called =) !
Author: mlouala
Submitted: 2017-01-07 07:22:24 UTC
Tags: Color, script editor, syntax, script, and syntax highlighting
Software: Maya
Views: 5,726
Related Items
-
Universal UV Randomization script for Maya 1.1.0 (maya script)
$20.00 (USD) -
Render Window / viewport Batch Render Script for Maya 1.0.0 (maya script)
$20.00 (USD) -
UV Texture Editor Tools Ur-edition for Maya 2.1.2 (maya script)
$39.00 (USD) -
Nightshade UV Editor Pro for Maya 2.1.3 (maya script)
$39.90 (USD) -
Christmas Color Ball 3D Model
$20.00 (USD) -
3D Thumbnail Generator (batch script) for Maya 0.3.1 (maya script)
$20.00 (USD) -
Attr Editor for Maya 1.3.0 (maya script)
$25.00 (USD) -
Color T-Shirt 3D Model
$38.00 (USD) -
Samsung Galaxy S6 All Color Pack 3D Model
$49.99 (USD)