Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 20-05-2023 , 01:01 PM
Registered User
Join Date: May 2023
Posts: 2

How to externally execute a .mel script file into the current scene rather than open

I have been learning scripting in Maya and so far so good.

One thing I would like to do is execute very simple ".mel" script files externally, with the goal of them changing something in a existing maya window. Very similar to ho THIS VSCode extension for Maya Mel script works.
Here is a video example of the extension:
user added image


I want to use this with AutoHotkey, a programming language suited for keyboard and mouse automation, to do something like:
Code:
Capslock & f::  ; when Capslock and f are pressed run the mel file "c:\temp\Layout4.mel". Which will change the active maya layout
Run, c:\temp\Layout4.mel
I know I can assign the above function to a keyboard key internally in maya. I have done that and I am now finding it to be limited. I do this with many other software's such as adobe Illustrator and Photoshop which let you execute arbitrary code in ''.jsx" files externally, which will have an affect on the open document.

The few things I have tried while a maya window is open are:
  • Double clicking a ".mel" script file in file explorer
  • in PowerShell invoking "Maya 'c:\temp\Layout4.mel'"
  • in PowerShell invoking "Maya -script 'c:\temp\Layout4.mel'"
  • in PowerShell invoking "Maya -command 'c:\temp\Layout4.mel'"

All of the above just lead to the creation of a new maya window that eventually open a new empty scene.

the only thing that worked was dragging "c:\temp\Layout4.mel" and dropping onto a maya window. The current layout instantly changes to 'Layout4'. Thats what I want but rather than drag and drop, just executing ".mel" file.

Any help would be greatly appreciated. Thanks.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads