Is it possible to keep object from switching to wireframe mode when you press 4?

Is it possible to keep object from switching to wireframe mode when you press 4?

malcolm_341
Collaborator Collaborator
2,278 Views
9 Replies
Message 1 of 10

Is it possible to keep object from switching to wireframe mode when you press 4?

malcolm_341
Collaborator
Collaborator

Hey, I'm looking for a way to keep a texture displaying in the viewport even after I press 4 to switch everything else in the scene to wireframe. I tried looking at how the image plane is working, but it doesn't appear to have a material applied to it. Is there some way to force the hardware drawing of a specific object(s) so they continue to display their textures in wireframe mode?

0 Likes
2,279 Views
9 Replies
Replies (9)
Message 2 of 10

stuzzz
Collaborator
Collaborator

hello,

 

Why about making a toggle grabScreen_104153349.jpgshortcut to override all the shape's scene except the one you want to display the texture.

the other shape will have an overrides with no shading.

 

 

0 Likes
Message 3 of 10

malcolm_341
Collaborator
Collaborator

Thanks, but it needs to be on the one specific object. It's for a mel script I created and the person using the script wants to press 4 as normal, but keep that one object from going into wireframe. Ideally there was just a flag or material I could apply to keep it from wireframe. I wonder what the special part of the image plane is that keeps it from changing into wireframe.

0 Likes
Message 4 of 10

00Six00
Contributor
Contributor

Hi @malcolm_341 

 

Im not exactly sure if I understood your question properly but i was able to come up with this a while ago. Select anything that has a texture applied to it or anything that you dont want affected and run the code. It makes use of @stuzzz  example of enabling overrides and toggling shading. InvertSelection is whats making this work. If you comment out InvertSelection, the code works as a Selective Wireframe Mode Toggle that one of my coworkers had requested but with a small modification, i think this can work for what you need.

global proc SelectionWireframe()
{ 
    InvertSelection;
    string $selected[] = `ls -sl`;
    string $s;
    for ($s in $selected)
    {
        int $wireMode = `getAttr ($s + ".overrideShading")`;
        
        if ($wireMode==1)
        {
            setAttr ($s + ".overrideEnabled") 1;
            setAttr ($s + ".overrideShading") 0;
            select -cl;
        }
        else
        {
            if ($wireMode==0)
            {
                setAttr ($s + ".overrideEnabled") 0;
                setAttr ($s + ".overrideShading") 1;
                select -cl;
            }
        }
    }
}

SelectionWireframe();

 PS. your tools are great!!

Message 5 of 10

malcolm_341
Collaborator
Collaborator

Thanks for your reply, but what I'm looking for is a way to flag an object to not switch into wireframe mode when the user press 4. The person I'm writing the script for doesn't want a custom hotkey they want to press 4 in vanilla Maya and the the object I created by running my script would ignore that render mode and stay shaded and textured. I was hoping there was a material or flag or extra attribute I could add to my mesh that would do this.

0 Likes
Message 6 of 10

00Six00
Contributor
Contributor

Ahh gotcha.

The above code would be a way of faking that i think. To refine it further, if there was a way to query which materials have textures applied to them in the scene, that would make it so that the code just runs automatically with out having to make any selections and leave textures displayed in the viewport. 

Ill look into seeing what makes 4 work and try and take it apart. 

0 Likes
Message 7 of 10

malcolm_341
Collaborator
Collaborator

Thanks, I took a look at the image plane because it has the functionality I want, but unfortunately it doesn't have a material applied and the render mode looks to be hard coded.

0 Likes
Message 8 of 10

stuzzz
Collaborator
Collaborator

You would have to rewrite a viewport with the API....

It would be a pain in the ass without C++ (not sure for python).

Or cheating by reimpleminting a locator drawoverride.

0 Likes
Message 9 of 10

malcolm_341
Collaborator
Collaborator

Definitely out of my scope at this time.

0 Likes
Message 10 of 10

kstarzyckaa
Community Visitor
Community Visitor

Hi!
This is actually very helpful for my case!
If you want to go back to "normal" settings - so everything acts the same no matter the wireframe or no you just replace every

.overrideEnabled

with 

.overrideShading

 And vice versa with overrideShading to overrideEnabled.

I guess any of you who understands coding will think it's obvious but for a person like me (not really understanding coding) it might be helpful.

0 Likes