Home Coding, Scripting, Shaders

[Maya MEL] Can you create a window with a UV editor view?

null
Offline / Send Message
Falxo null
As far as I'm aware, most UI elements in Maya can be added in custom UI windows.
For example, you can create windows with a scene's viewport ("modelEditor"), blend shape editor ("blendShapeEditor") and the node editor ("nodeEditor"). You can arrange them however you want and as many as you want.

But so far I haven't managed to find one that can do the same for a UV editor.
I have found, after a bit of searching, the command "textureWindow" (not the name I was expecting to be honest) that claims to do this exact thing.


But no matter what I do, it doesn't seem to want to create an instance of itself, returning an error.

"// Error: line 1: Unable to create more than one texture window. //"

So, the next thing to logically try is to re-parent the existing one to a new window.
But that doesn't seem to result into anything other than empty windows.
On top of that, I can't be certain that I'm getting the right name of the existing one by using the example found in the documentation of that command.

"getPanel -sty polyTexturePlacementPanel"

This is really confusing. Why is this particular UI element so difficult to work with?

Additionally, after trying a few different possible word combinations, I have accidentally found out that there is a "texturePanel" command.
There is no documentation of it anywhere and I just found out about it. I don't know what arguments it requires and how exactly does it differ from the other one. I will post back here if I figure it out and if it is actually useful.
Until then, I would like to hear your recommendations on this.

Is there a way to create a window with a UV editor/viewer in Maya via MEL?


Replies

  • Falxo
    Options
    Offline / Send Message
    Falxo null
    Ok, good news and bad news.

    Good news:
    I managed to find a way to display the existing texture editor (which it would make a ton more sense if it was simply called UV editor) into a window. Apparently I was doing something wrong before resulting in empty windows, re-parenting the existing one DOES work. You can try it too by first closing any existing windows that have a UV view on them (most likely UV Editor) and then running the example MEL script below:

    {<br>&nbsp;&nbsp;&nbsp; string $inspWindow=`window -title "Inspector Assistant Window" -iconName "Inspector" -width 400 -height 400 "ui_InspectorAssistant_Window_UserInterface#"`;<br>&nbsp;&nbsp;&nbsp; string $inspFrmLay=`formLayout -parent $inspWindow "ui_InspectorAssistant_FormLayout_UserInterface#"`;<br><br>&nbsp;&nbsp;&nbsp; string $txtrExstPnl_Array[]=`getPanel -sty polyTexturePlacementPanel`;<br>&nbsp;&nbsp;&nbsp; string $txtrExstPnl=$txtrExstPnl_Array[0];<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; textureWindow -edit -parent $inspFrmLay $txtrExstPnl;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; formLayout<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -edit<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -attachForm $txtrExstPnl "top" 0<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -attachForm $txtrExstPnl "left" 0<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -attachForm $txtrExstPnl "bottom" 0<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -attachForm $txtrExstPnl "right"&nbsp; 0<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $inspFrmLay;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; showWindow $inspWindow;<br>}

    Now for the bad news.
    As you may have noticed in the paragraph before, I recommended you to close your UV Editor before running the script. That's because there can only be one viewer at a time in all of the application. For example, it doesn't behave like the Model Editor viewport, where you can have as many views of the same or different cameras as you desire. If you try to run the script while already having a UV view anywhere in the application, it will result into errors and one of the viewers is going to disappear.

    That shouldn't be that big of a surprise when at the very beginning I mentioned that, in order to do this, the script will need to re-parent the existing UV view to a new piece of UI. It would have a been a lot easier if the "showWindow" command allowed for the creation of a new UI element, but it still refuses to. Maya is adamant on allowing only one to exist in the entire application, viewable or not.

    I can't consider this a proper solution, as I will need to add a couple of lines in the script to close any existing windows that are already using a UV view on them, and this may displease any third-party users it might be used by.

    Any ideas for the creation of new independent UV Editors are still welcome.
Sign In or Register to comment.