Home Technical Talk

Maya Material Interface Tool

polycounter lvl 12
Offline / Send Message
Bartalon polycounter lvl 12
Hey guys, thanks to a few of you I was able to hack together a MEL script that I've wanted to make for a while now. I've always been pissed off with Maya's menus when it came to assigning existing materials, constantly having to choose Material Attributes to display a material, and opening the Hypershade all the time is annoying... So I made a little window to take care of it for me.

[UPDATE]

On the plus side, this may be useful when working with dDo's material library, as seen below:

matList_Docking.PNG

You can try it out here:

Material List

Installation instructions come with the ZIP file.

I'd be interested to know what you guys think.

Replies

  • FlynT
    Offline / Send Message
    FlynT polycounter lvl 8
    Nice, this will come in handy! Thanks for sharing :)
  • chenguan
    hi there Bartalon this tools is very interesting, simple and break some tedius tasks in maya.
    there are two suggestions i like to make .
    first a button to (select objects with Material) and some way to identify the shaders that have textures applied.

    to finish is a bit stressful when you move the windows to some place and you use (delete button) and the windows pops to inicial place, but maybe this is maya related.
    just some ideas
    best regards and thanks
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    Thanks for the feedback chenguan. Those suggestions are really great and I've implemented the window positioning and selecting objects with matching materials. Identifying the shader will take me some more time but I'll get around to it at some point.

    I've also added buttons to switch between alphabetical and chronological ordering.

    When listing alphabetically, it seems to alphabetize materials that begin capitalized first, then alphabetize materials that are lower case second, so "A" and "a" will be on opposite ends of the list. Close enough... haha

    You should be able to re-download the script from my original post and replace the old file.
  • sculptn
    Offline / Send Message
    sculptn polycounter lvl 7
    Nice job looks very useful.
  • Toast
    Offline / Send Message
    Toast polycounter lvl 11
    Great idea and thanks for the share.

    I edited it to remove referenced materials, but how does one also remove the new assemblyNode-d materials???

    string $materialsbgone[] = `ls -mat -rn -as`;

    doesn't seem to catch assembly materials? (but it does catch referenced materials)???
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    I'm not familiar with assembly materials, but I imagine they could be removed with the stringArrayRemoveExact command the same way I remove the partcileCloud1 object. If anyone knows about assemblies I could try working that in.

    I've also updated the file to remove some superfluous code as well as make the Hypershade icon follow lambert1 after reorganizing the list.
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    Sorry, double post.
  • chenguan
    Bartalon great stuff.

    first i have createAssignNewMaterialTreeLister ""; assign to hotkey m.
    the new button (select object with material) works great with my hotkey .both windows work great at same time. for me this is a great worflow.fast to change materials if i need.(you interface is great and simple) (clicking material bar brings atributes editor, clicking (S) and createAssignNewMaterialTreeLister "" is great to assign new shader with atributes editor closed ),i love this.
    some problems im sure you know them.
    if any shader from mental ray or any other engine is listed in hypershade, your tool cant be sourced.
    new shaders cgfx same problem.maybe to much work to make it work with all this shaders, but your tools working ignoring those shaders is needed:P

    2- the space between s and assign tool is for future planning for "rename material"? :P
    3- the rgb cmy button i think is easy to costumize i will try to make one of those shaders a checker material. maybe using the assign checker shader from bonus tools.

    dont get me wrong with all this stuff,if the problem from others materials is gone, your tool is a must have.


    cheers
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    chenguan wrote: »
    if any shader from mental ray or any other engine is listed in hypershade, your tool cant be sourced.
    new shaders cgfx same problem.

    I have updated the tool already so you should try downloading it again! Any material that does not have a "color" channel will be colored pink in the Material List window now.

    A rename button will be easy to add, and I will get to that later today when I am available.
  • chenguan
    Bartalon thxs for the update, my mistake replacing the files.working as expected.
    here a image with your tool in action with some little changes.just small layout changes,to suite my others tools.
    i mentioned in the image the rename button, if you can make it pop up a little box (maybe with annotation note as reference) to rename will be amazing.
    many thxs this should come in maya 2014 by default:)
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    Thanks for more suggestions and the kind words! I have implemented and fixed a lot of stuff.

    I overhauled the parenting inside the matList proc so everything should be much neater to look at. I've also added some comments to help out with navigation.

    You can re-download for an update. You'll have to go through and set all your custom colors again. Sorry!
  • Money
    Offline / Send Message
    Money polycounter lvl 8
    Great script, always wanted something like this. Thanks :D

    Also one suggestion for scenes when working with lots of different materials. Maybe under that refresh button there could be another one that would enable highlighting of the ones used on the selected model. Pic shows it better.

    highlightafueg.jpg
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    That's a great idea. I'll look into that.

    Your screen shot shows an older version of my script. You might want to re-download it from my original post, as there have been significant updates.

    Here's a shot of what the most recent version of this tool looks like:

    matlist.PNG
  • chenguan
    Bartalon great rename works great, the layout looks better every day, i downloaded the new but it dont come with the (new) button ,. will it call the createAssignNewMaterialTreeLister ""; command. Money suggest the highlight of the selection button. in scene with lots of materials can be handy.
    congratulations. time to organize all my scene, they in need.
    cheers keep the great work, this tool cant improve much more,)
  • Toast
    Offline / Send Message
    Toast polycounter lvl 11
    Added this line of code to line 231

    swatchDisplayPort -wh 2 2 -sn $materials[$i] -pressCommand ("select -r "+$materials[$i]+ ";NodeEditorWindow");

    THANK YOU FOR THIS TOOL!
  • chenguan
    Toast i will love a button like that one to automatic map a texture in color and open the browser ;P one of this days this tool will be multi task. you how if can be made
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    Hey guys, glad to hear you're liking the changes. I've made some further adjustments. I also realized I was saving my updated file to the wrong folder haha. Re-download now for significant modifications.
    Money wrote:
    Also one suggestion for scenes when working with lots of different materials. Maybe under that refresh button there could be another one that would enable highlighting of the ones used on the selected model.

    I shifted some elements around to accommodate this. I don't think button highlighting is possible so I went with the next easiest thing. I added a column which will indicate any assigned materials to a selection when you hit Refresh. These indicators will persist until you hit refresh again, even if you deselect your object. See below

    matlist.PNG


    I widened the panel by 25 pixels to allow room for a fifth button column (to the left of ), which I left blank for those who would like to add their own custom command. Line 254 contains a blank spot for this. There's also plenty of room down at the bottom between the Clear/Delete and Undo/Create buttons if you want to stay within the window's real estate.

    chenguan wrote:
    Bartalon great rename works great, the layout looks better every day, i downloaded the new but it dont come with the (new) button ,. will it call the createAssignNewMaterialTreeLister ""; command.
    If you refer to the image above, the window on the right is what appears when you click New. Currently, the New button will only initially work with an object selected. After this has been used once (during the current Maya session), you may create new materials without having an object selected. This will add it to the scene but not apply it to anything. Due to the way the MaterialTreeLister works, you will have to manually refresh the list for it to show up. A pain, I know :)

    There is an issue which is inhibiting my progress on some other tools I've been making where commands similar to this are not sourced until they are used the intended way for the first time (my biggest peeve is the AEFileTextureBrowser)
    Toast wrote:
    Added this line of code to line 231

    swatchDisplayPort -wh 2 2 -sn $materials[$i] -pressCommand ("select -r "+$materials[$i]+ ";NodeEditorWindow");

    With this current version, you can add this back into my tool at line 254.

    Edit: I've also rearranged the buttons slightly so it's not such a hassle finding the Assign button.
  • Money
    Offline / Send Message
    Money polycounter lvl 8
    That gets the job done. :D Thanks
  • chenguan
    Bartalon the highligh is a problem becose require always refresh.
    here a image with a suggestion. i dont know mel otherwise i will try it:p

    maybe replace the select object with material(s) with the tick i put in the image so the button wills elect it and highlight it. if you think is a solution and you like the layout. i think the best layout is the right one.the left is more like assign material and make it selected not sure whats better. the righ one will make no problem assigning materials too.
    cheers
  • Bartalon
    Offline / Send Message
    Bartalon polycounter lvl 12
    The problem with windows (as far as I understand) is that they do not update in real time. Any changes to the information must be updated manually, such as entering information, clicking buttons, checking check boxes, marking bubbles, etc.

    I think having to click Refresh every so often is a fair exchange for the convenience the tool provides!

    Also, if I'm wrong about this I'd love to know haha. I could make my tools so much better!
  • chenguan
    the refresh is no problem at all is great solution for the limitations from mel maybe.just think the refresh for the highlights is a bit fest click.but i cant see in maya any solution to the highlight.most are change colors, and will not be welcome to your tool.the materials list with the right shader color is great.

    if i undestand you mean the (thick) solution will have the ame problem and will need refresh.
Sign In or Register to comment.