View Full Version : writing a simple toggle?

10 October 2004, 03:57 AM

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:

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

i saved it as a perl file and named it ""
then i typed "@E:\modoStuff\scripts\" 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,

10 October 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

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

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.

if(lxq("viewport.3dView wireframe:?") == "none")
lx("viewport.3dView wireframe:\"colored\"");
lx("viewport.3dView wireframe:\"none\"");


10 October 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:

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:

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:

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

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 January 2006, 11: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.