PDA

View Full Version : writing a simple toggle?


zeebit
10-05-2004, 03:57 AM
Hello,

I am used to mel, and have no experience in perl, unfortunately.
i was wondering if anyone can help me out in writing a simple toggle that i can then bind to a key.
something like a wireframe toggle.
i just want to be able to switch from no wire to colored.
this is what i wrote, but it doesn't work, hehe:

#perl
if((viewport.3dView wireframe:?) == "none")
{viewport.3dView wireframe:"colored";}
else
{viewport.3dView wireframe:"none";}


i saved it as a perl file and named it "wireframeTGL.pl"
then i typed "@E:\modoStuff\scripts\wireFrameTGL.pl" into the cmd line.
it said it was a success in the results, but nothing happens, and i am not quite sure how to use lxout and stuff yet.

thanks for your time,
-zeebit

kursad_pileksuz
10-05-2004, 04:57 AM
why do not you just use a single command line and assign to a shortcut?. i have assigned many shortcuts to different view functions, like enabling vertices, wireframe etc. just run the viewport properties and enable something and track it from command line, i am guessing that you knew this but just in case

zeebit
10-05-2004, 05:17 AM
i love your shit kursad, just so you know.
i check your site all the time.
hehe

i wanted to have a single button that can toggle the functionality as opposed to having to make a button for on and a button for off.

armaduck in #luxology on efnet helped me make this modo compliant.

#perl
if(lxq("viewport.3dView wireframe:?") == "none")
{
lx("viewport.3dView wireframe:\"colored\"");
}
else
{
lx("viewport.3dView wireframe:\"none\"");
}

-zee

visualride
10-05-2004, 03:42 PM
If you look in your resource directory (on my computer it is in: C:\Documents and Settings\Me\Application Data\Luxology\modo\resrc) you will find: MSWireframeToggle.pl.

This does just what you want. There are a few options that I like to toggle off and on, so I assigned them to a pie menu. Search in here about pie menu's, because someone (I forget who) wrote very descriptive steps on how to set them up. Here's the contents of the wireframe toggle perl program:

#perl
my $cages, $guides;
$wire = lxq("viewport.3dView wireframe:?");
if ($wire) {
$wire = 0;
}
else {
$wire = 2;
}
lx("viewport.3dView wireframe:$wire");

Now I have a question for all the perl gurus that might view this. I was trying to create my own toggle for changing select style from lasso to rectangle. Here is what I got:

#perl
my $selStyle;
$selStyle = lxq("select.lassoStyle:?");
if ($selStyle) {
$selStyle = 0;
}
else {
$selStyle = 1;
}
lx("select.lassoStyle:$selStyle");


I'm new to perl. Anyone know how I may debug this? Anyone know how I might be able to step through this code line by line and see the value of the variables?

Anyways, I hope this is what you needed zeebit. Good luck.

CGTalk Moderation
01-19-2006, 10:00 AM
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.