Home Technical Talk

Maya - find a mesh in Layers

Ok, so if you select an object and press "f" in the Outliner window, the mesh name gets highlighted and the outliner jumps to its location in the list.

However, if you want to find out which layer something is on, you seem to have to name it right from the start, in order to find it again. Is there no way to find a mesh by clicking it and getting Maya to tell me which layer it is on?

I'm sure this is a question that has been answered, but I couldn't find anything on it. I can select all meshes from a layer, so why can't I select layers from a mesh? It would be really handy to know if and how that works!

Thanks!

Replies

  • [Deleted User]
    Offline / Send Message
    [Deleted User] polycounter lvl 3
    Slower way:
    You could list all layers in the scene and check which have your object.

    Faster way:
    If you look in node editor you will see that yourLayer.drawInfo output is connected to yourMesh.drawOverride input. Just check what is the name of the layer there with MEL/Python/C++/C# or whatever is your poison ;).

    I'm not a Maya guy but I may look into it if you don't know scripting/API. Just don't count that you will get it today :).
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    isnt the layer name, one of the inputs of any object in a layer? should be able to see it right in the channel box?

    if that isnt enough i could make you a little bit of python that finds and selects the layer of the selected object or prints the name.

    off the top of my head here is the code to have have the layer name print to the console
    import pymel.core as pm
    
    import pymel.core as pm
    
    sel = pm.selected()
    for i in sel:
        print i + ' in layer ' + str(i.listConnections(type='displayLayer'))
    
  • Sinking
    Thanks for the replies guys! I come from using XSI and I simply find it a bit odd that the Maya layers have partly the same functionality. It just seems like you would want to know which object a layer is on, as opposed to only knowing which meshes are in a layer.

    I really prefer Maya to XSI, but it seems odd that there is no function that simply lets you rightclick on an object and say "find layer". That would be perfect. I don't really want to type a script, though I guess I could make it into a button!

    Thanks Passerby, I will check that out. Wasn't aware this is really not in the core program. I like working with layers (too much perhaps).

    >>EDIT: YOU ARE RIGHT! The layer is always the top entry in the INPUTS in the Channel Box. I never checked there for the layer name, but apparently that is the easiest way to find it! Thanks for the hint! I am still finding my way around Maya, looking for stuff :)
  • [Deleted User]
    Offline / Send Message
    [Deleted User] polycounter lvl 3
    If you are on Windows and Maya 2014 here is the compiled DLL and the source code for C# version.
    It will print:
    FindLayer()
    
    // "{object} is connected to "{name}" layer" //
    


    Download:
    http://www.mediafire.com/?m1qetmycuphdq93
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    @mantragora, what is the point of a c# version than running a mel command, when it is only 3 lines of python code, that work on almost all versions.

    @Sinking, ya layers are kinda odd, i either look at the channel box inputs section, or i create groups, assign the layer to just the group, and drag objects into said group.

    in maya for pure organization i find groups do a better job, but i assign them to layers sometimes, so i can either set all the contents to not render, or set them to reference mode.
  • [Deleted User]
    Offline / Send Message
    [Deleted User] polycounter lvl 3
    passerby wrote: »
    @mantragora, what is the point of a c# version than running a mel command, when it is only 3 lines of python code, that work on almost all versions.

    Fun? C# API is similar to C++ API, so translating this to C++ is piece of cake. Some may like it.

    Beside this, if you get some new function in Maya 2015 you will not use it too because it's not available in other versions? So I suppose you are still using only Maya 1.0 functions?
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    mantragora wrote: »
    Fun? C# API is similar to C++ API, so translating this to C++ is piece of cake. Some may like it.

    Beside this, if you get some new function in Maya 2015 you will not use it too because it's not available in other versions? So I suppose you are still using only Maya 1.0 functions?

    just seems you were doing a lot of extra work in the api, when the exact same thing can be done with less code in mel, or python via cmds or pymel. when in the end execution is almost the same anyways.

    i tend to switch between the api, and scripting depending on the what needs to be done, and since the api is good for implementing new nodes, tools, file translators, or anything that needs to iterate over a lot of data, but requires way way more code to do the simple things that the scripting engines can do with very easy to understand simple lines of code.

    also legacy is important too since not that many have moved over to 2014 especially the game studios. i know a lot of people still on 2012 and some still on 2010.

    @Sinking

    if you would like i could make the script also toggle options for the layer the selected object is in too.
  • [Deleted User]
    Offline / Send Message
    [Deleted User] polycounter lvl 3
    In one topic there is covered every possible way to get the same output. It's an example, not a topic about who will do this shorter/faster.

    Cheers
Sign In or Register to comment.