PDA

View Full Version : Wireframe Script Please Help


nubian
11-04-2005, 07:03 AM
i'm trying to find a way that i can switch back and forth between wireframe on shaded mode and no wireframe on shaded in any view panel but my mel is not all that great.

i thought it would be something like this:
modelEditor -e -wos 0;

but the scipt editor is telling giving me an error telling me this:
// Error: No object name specified. //

please help.
any help will be greatly appreciated.
thanks in advance

goleafsgo
11-04-2005, 10:21 AM
You have the right command but it is panel specific, so you have to provide the name of the panel to switch it on. I can't remember the exact commands but you need to get the panel with focus, or the panel under the mouse, and then check that it's a modeling panel and then pass it on to the modelEditor command.

If someone doesn't beat me to it I'll post the few lines to get the panel name when I get to work.

Jhavna
11-04-2005, 02:48 PM
You'll be wanting the name of the panel to do any changes to its rendering settings. you can get that using:

$current_panel = `getPanel -wf`;
$panel_type = `getPanel -to $current_panel`;


This will get the name of the currently active viewport.

use $current_panel to set the viewport shading settings.

modelEditor -e -wos 0 $current_panel;

$panel_type needed later on.. see below...

mhovland
11-04-2005, 05:18 PM
Here is a finished version that I had a request from an office mate to write this morning.


global proc toggleWireframeOnShaded()
{
string $panel = `getPanel -wf`;

if(`getPanel -to $panel` == "modelPanel")
{
if(`modelEditor -q -wos $panel`)
modelEditor -e -wos 0 $panel;
else
modelEditor -e -wos 1 $panel;
}
}

nubian
11-05-2005, 12:30 AM
wow, awesome!
thanks! :bowdown:


You'll be wanting the name of the panel to do any changes to its rendering settings. you can get that using:

$current_panel = `getPanel -wf`;
$panel_type = `getPanel -to $current_panel`;


This will get the name of the currently active viewport.

use $panel_type to set the viewport shading settings.

modelEditor -e -wos 0 $current_panel;
this works, is there i way i can set this in an if statement?
i have no way of swtiching back and forth.



Here is a finished version that I had a request from an office mate to write this morning.


global proc toggleWireframeOnShaded()
{
string $panel = `getPanel -wf`;

if(`getPanel -to $panel` == "modelPanel")
{
if(`modelEditor -q -wos $panel`)
modelEditor -e -wos 0 $panel;
else
modelEditor -e -wos 1 $panel;
}
}

thanks, but this does not work. :shrug:

Jhavna
11-05-2005, 01:11 AM
sure is:
$current_panel = `getPanel -wf`;
$panel_type = `getPanel -to $current_panel`;
$is_wireframe_on = `modelEditor -q -wos $current_panel`;

if ($panel_type == "modelPanel")
{
if ($is_wireframe_on == 1)
{
modelEditor -e -wos 0 $current_panel;
}
else
{
modelEditor -e -wos 1 $current_panel;
}
}

At least that's what I think it should be. Not tested this but hopefully it'll work ;)
oh yeah, if you plan using this as a shelf button script, wrap it in a pair of {'s else the variables will be global.

nubian
11-05-2005, 01:14 AM
you guys are incredible! :bounce:
thanks for the speedy response! :thumbsup:

Jhavna
11-05-2005, 01:16 AM
Speedy? you replied while I was editing my post.. that's speedy! Hope it helps....

nubian
11-05-2005, 04:45 AM
yes it does work!
thank you.

mhovland
11-06-2005, 03:05 PM
thanks, but this does not work. :shrug:

Are you calling the procedure from a shelf button or keyboard shortcut? My script and Jhavna's do exactly the same thing, only in different ways. Making them good candidates to look at and learn a bit about the different approaches one can take while scripting.

nubian
11-06-2005, 04:57 PM
Are you calling the procedure from a shelf button or keyboard shortcut? My script and Jhavna's do exactly the same thing, only in different ways. Making them good candidates to look at and learn a bit about the different approaches one can take while scripting.

after doing some extensive research and reading of my "mel scripting for maya animators" book, i didn't realize i had to place this script into the scripts directory and call it by the global procedure name.
what i did originally is that i placed your script into the script editor and even though it did not give me any errors, it just did not work this way.

though i'm not too familar with this method i do believe this is an intuitive way of using custom scripts.
thank you

seven6ty
11-06-2005, 06:09 PM
I'm pretty sure there's an easier way to do this, I'll post up the script I use at work, but it should be as easy as querying the current state of the window under point, and then editting that and setting it to ! (The opposite) of that state. Like I said, I'll post up yet another approach tomorrow.

seven6ty
11-07-2005, 06:31 PM
Ah, this is for Xray mode, to toggle it on and off, a tiny bit different than what you were asking, but I'm pretty sure just about the same approach can be used, and like I said, it's much briefer coding:

{
string $curPanel = `getPanel -underPointer`;
int $xraySet = !`modelEditor -q -xray $curPanel`;
modelEditor -e -xray $xraySet $curPanel ;
}

nubian
11-09-2005, 03:08 PM
Ah, this is for Xray mode, to toggle it on and off, a tiny bit different than what you were asking, but I'm pretty sure just about the same approach can be used, and like I said, it's much briefer coding:

{
string $curPanel = `getPanel -underPointer`;
int $xraySet = !`modelEditor -q -xray $curPanel`;
modelEditor -e -xray $xraySet $curPanel ;
}


oooo thanks!
i had a script that involved much more work.

i had it so where maya would toggle back and fourth frame 1 and 2.
on the transparency attribute of a shader i would set keys so that on frame 1 it was opaque and on frame 2 it was somewhat see through.

your script will help me so much.
thank you

Jhavna
11-09-2005, 03:20 PM
On my site I have two xray scripts - Xray viewport (xrays everything in a viewport) and Xray objects (toggles xray for selected objects) I've had a number of comments and requests for them and so they now support a variety of stuff (like xray on instanced objects and objects in component mode)

http://www.jhavna.net

might be useful too

Just copy paste it into the script editor, select it and middle drag to the shelf

CGTalk Moderation
11-09-2005, 03:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.