Author Topic: Toggle Variables?  (Read 4535 times)

0 Members and 1 Guest are viewing this topic.

VerticalMojo

  • Guest
Toggle Variables?
« on: January 28, 2005, 04:02:36 PM »
Using a macro, is there a way to toggle a variable?

Example: Gripblock: toggle between 0 and 1

*Edit* I ment 0 - 1 not 1 - 2  :roll:

Zydenet

  • Guest
Toggle Variables?
« Reply #1 on: January 28, 2005, 04:40:10 PM »
Do you mean between 0 and 1?

Try this for a button

Code: [Select]
(setvar "GRIPBLOCK" (- 1 (getvar "GRIPBLOCK")))

or for a command line version

Code: [Select]
(defun c:GB ()
(setvar "GRIPBLOCK" (- 1 (getvar "GRIPBLOCK")))
(princ)
)

JohnK

  • Administrator
  • Seagull
  • Posts: 10651
Toggle Variables?
« Reply #2 on: January 28, 2005, 04:58:23 PM »
Like this?

Command: (setvar "GRIPBLOCK" (boole 6 (getvar "GRIPBLOCK") 1))
1

Command: (setvar "GRIPBLOCK" (boole 6 (getvar "GRIPBLOCK") 1))
0


* Edit:
Sorry, i should prolly use the Var. you wanted to use in my example. I fixed my example to use the variable you used in your question.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VerticalMojo

  • Guest
Toggle Variables?
« Reply #3 on: January 28, 2005, 04:59:52 PM »
Yeah thats what I ment, 0-1.

I need it done without the use of LISP. Most computers here have AutoCAD LT.

I wish everbody had it, it would make my life a lot easier! Maybe soon. :roll:

JohnK

  • Administrator
  • Seagull
  • Posts: 10651
Toggle Variables?
« Reply #4 on: January 28, 2005, 05:03:21 PM »
huh?! Does LT support Diesel? (I hope diesel has a "boole" function. :D Im gonna go look.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VerticalMojo

  • Guest
Toggle Variables?
« Reply #5 on: January 28, 2005, 05:19:19 PM »
Quote from: Se7en
huh?! Does LT support Diesel? (I hope diesel has a "boole" function. :D Im gonna go look.)


It does support Diesel.....

JohnK

  • Administrator
  • Seagull
  • Posts: 10651
Toggle Variables?
« Reply #6 on: January 28, 2005, 05:27:55 PM »
Have you ever read this document?

http://www.crlf.de/Dokumente/Diesel/Diesel.html
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Toggle Variables?
« Reply #7 on: January 28, 2005, 05:30:14 PM »
Not relevent to you, but just to show:
Code: [Select]
(if (=(getvar "osnaphatch")0)(setvar "osnaphatch" 1)(setvar "osnaphatch" 0))

JohnK

  • Administrator
  • Seagull
  • Posts: 10651
Toggle Variables?
« Reply #8 on: January 28, 2005, 05:33:39 PM »
Hey Dommy, Re-read my first post. (using Boole is a much cleaner way to do what your doing in that statement.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VerticalMojo

  • Guest
Toggle Variables?
« Reply #9 on: January 28, 2005, 05:34:49 PM »
Quote from: Se7en
Have you ever read this document?

http://www.crlf.de/Dokumente/Diesel/Diesel.html


Yeah, its been awhile and I really didn’t figure out how to do it well. How would I execute the Diesel command you gave me?

JohnK

  • Administrator
  • Seagull
  • Posts: 10651
Toggle Variables?
« Reply #10 on: January 28, 2005, 05:38:44 PM »
I didnt give you a diesel command. But if you read that page cloesly, youll get lead to this page with gives you the syntax of each diesel command.

http://www.fourmilab.ch/diesel/

Follow the links on that page and you can get some really cool ideas. He even gives examples so im sure you can figure out how to toggle the variable.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VerticalMojo

  • Guest
Toggle Variables?
« Reply #11 on: January 28, 2005, 05:53:37 PM »
Quote from: Se7en
I didnt give you a diesel command. But if you read that page cloesly, youll get lead to this page with gives you the syntax of each diesel command.

http://www.fourmilab.ch/diesel/

Follow the links on that page and you can get some really cool ideas. He even gives examples so im sure you can figure out how to toggle the variable.



That’s what I thought, but I wasn’t sure since you probably know more about it than I do! Thanks for the links though!  :) I will check them out this weekend.

By the way, you guys have a good weekend! see ya on monday!

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Toggle Variables?
« Reply #12 on: January 29, 2005, 09:13:56 AM »
Thanks Se7en, I'll look into that.  Gotta get more advanced sometime :twisted:

VerticalMojo

  • Guest
Toggle Variables?
« Reply #13 on: February 04, 2005, 05:54:34 PM »
^C^Cgripblock $M=$(-,1,$(getvar,gripblock))

thanks 7....

 :)

Zydenet

  • Guest
Toggle Variables?
« Reply #14 on: February 04, 2005, 08:38:53 PM »
I'm sorry. I didn't realize you didn't have one yet. All you needed to do was add ^C^C in front of (setvar "GRIPBLOCK" (- 1 (getvar "GRIPBLOCK"))) in my first post.

Code: [Select]
^C^C(setvar "GRIPBLOCK" (- 1 (getvar "GRIPBLOCK")))

VerticalMojo

  • Guest
Toggle Variables?
« Reply #15 on: February 07, 2005, 01:41:03 PM »
Sorry Zydenet, didnt realize you had it posted thanks!

It was fun messing with Diesel to figure it out though!

 :)

VerticalMojo

  • Guest
Toggle Variables?
« Reply #16 on: February 07, 2005, 02:27:15 PM »
I have LT so I needed to convert it to Diesel in order for it to work...