Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please help with transparent Osnap toggle

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
152 Views, 3 Replies

Please help with transparent Osnap toggle

Hi Everybody,

I want to be able to toggle my osnap settings from 0 to 41,
and vice versa, and I want this to be transparent. (even in lisp routines).

I wrote a little "if" test, and made a vlax command out of it
to make it transparent. See below:

(vl-load-com)
(defun c:tgl (/ a)
(setq a(getvar "osmode"))
;(setvar "cmdecho" 0)
(if (/= a 41)
(setvar "osmode" 41)
(setvar "osmode" 0)
;;;(command "'-osnap" "end")
;;;(command "'-osnap" "non")
)
)
(vlax-add-cmd "osmode-tgl" 'tgl "osmode-tgl" 1)


My problem is:
the setvar functions are sending their data (41 or 0)
to the command I am in, and messing it up.
For example, If I am in the "line" command, and I
run the program "'TGL", it either sends the 41 and makes
a line 41 units long, or sends the 0 and makes a 0 length line!

Any ideas on how to make it stop? You can see I tried a couple
of things that I have "commented out", but they didn't help.

Any ideas on this, or alternate suggestions for doing this will
be greatly appreciated.

Thanks,
Steve
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Steve,

Joe LeBaron's thread 9/1/01 called "Transparent Lisp Command (OSNAP)" might
be relevant?

Joe Burke

"Steve Adams" wrote in message
news:C54D0A22F309955D4B0E7F2A4E7C5287@in.WebX.maYIadrTaRb...
> Hi Everybody,
>
> I want to be able to toggle my osnap settings from 0 to 41,
> and vice versa, and I want this to be transparent. (even in lisp
routines).
>
> I wrote a little "if" test, and made a vlax command out of it
> to make it transparent. See below:
>
> (vl-load-com)
> (defun c:tgl (/ a)
> (setq a(getvar "osmode"))
> ;(setvar "cmdecho" 0)
> (if (/= a 41)
> (setvar "osmode" 41)
> (setvar "osmode" 0)
> ;;;(command "'-osnap" "end")
> ;;;(command "'-osnap" "non")
> )
> )
> (vlax-add-cmd "osmode-tgl" 'tgl "osmode-tgl" 1)
>
>
> My problem is:
> the setvar functions are sending their data (41 or 0)
> to the command I am in, and messing it up.
> For example, If I am in the "line" command, and I
> run the program "'TGL", it either sends the 41 and makes
> a line 41 units long, or sends the 0 and makes a 0 length line!
>
> Any ideas on how to make it stop? You can see I tried a couple
> of things that I have "commented out", but they didn't help.
>
> Any ideas on this, or alternate suggestions for doing this will
> be greatly appreciated.
>
> Thanks,
> Steve
>
>
>
>
>
>
>
>
Message 3 of 4
Anonymous
in reply to: Anonymous

Is this what you are looking for?

(vl-load-com)
(defun c:tgl (/ a)
(setq a (getvar "osmode"))
(if (/= a 41)
(setvar "osmode" 41)
(setvar "osmode" 0)
)
(princ);<--- Added this
)
(vlax-add-cmd "osmode-tgl" 'tgl "osmode-tgl" 1)

Something else to chew on:

;toggles osnaps on and off regardless of osnap setting
(defun c:tgl ()
(setvar "osmode" (boole 6 (getvar "osmode") 16384))
(princ)
)
(vlax-add-cmd "osmode-tgl" 'tgl "osmode-tgl" 1)
--

Regards,
Eric S.
eschneider@jensenprecast.com
Message 4 of 4
Anonymous
in reply to: Anonymous

Eric,

Thanks a lot for your solution. I really do appreciate it.
And thanks for the boolean toggle example, too.

Steve


Eric S. wrote in message
news:A42F2E072EF104DC20E2E296414CF1D5@in.WebX.maYIadrTaRb...
> Is this what you are looking for?
>
> (vl-load-com)
> (defun c:tgl (/ a)
> (setq a (getvar "osmode"))
> (if (/= a 41)
> (setvar "osmode" 41)
> (setvar "osmode" 0)
> )
> (princ);<--- Added this
> )
> (vlax-add-cmd "osmode-tgl" 'tgl "osmode-tgl" 1)
>
> Something else to chew on:
>
> ;toggles osnaps on and off regardless of osnap setting
> (defun c:tgl ()
> (setvar "osmode" (boole 6 (getvar "osmode") 16384))
> (princ)
> )
> (vlax-add-cmd "osmode-tgl" 'tgl "osmode-tgl" 1)
> --
>
> Regards,
> Eric S.
> eschneider@jensenprecast.com
>
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost