PDA

View Full Version : Lisp routine turns off my OSNAPs - very annoying!



Cadastrophic
1st Nov 2004, 09:22 pm
Here I go again. I've found a very useful lisp that adds a Z-break line. The only problem is, when I use it, it turns off the OSNAPs. It's not a huge problem, as all I have to do is hit F3 and reselect them all before proceding, but it's just damned anoying.
Has anyone any suggestions please?
Here's the code as I've loaded it:

(defun c:brr (/ p1 p2 p3 p4 p5 p5a p6 d1 d2 d4 dd2 api a1 a2 a3 )
(setq osn (getvar "osmode"))
(setvar "osmode" 0)
(setq p1 (getpoint "\n First point: "))
(setq p2 (getpoint p1 "\n Second point:"))
(command "line" p1 p2 "")
(setq d1 (distance p1 p2))
(setq d2 (* d1 0.1));=== change the number in this line to adjust the size of zig-zag
(setq api (/ pi 180))
(setq a1 (angle p1 p2))
(setq a2 (+ a1 (* api 63)))
(setq p3 (polar p2 a2 d2))
(setq a3 (+ a1 (* api 284)))
(setq dd2 (* d2 (sin (* api 63))))
(setq d3 (/ (* dd2 2) (cos (* api 14))))
(setq p4 (polar p3 a3 d3))
(setq p5 (polar p4 a2 d2))
(setq p5a (getpoint p5 "\n Third point:"))
(setq d4 (distance p5 p5a))
(setq p6 (polar p5 a1 d4))
(command "line" "" p3 p4 p5 p6 "")
(setvar "osmode" osn)
(princ)
)
(princ "\n Type < brr > to draw Breakline Symbol: ")

Dommy2Hotty
1st Nov 2004, 09:43 pm
***DOES NOT APPLY ANYMORE, SEE EDIT***No big change, just declared the "OSN" variable as local instead of global. Should work with no problem. Just make sure your osmode is correct before you run it next time, because if your OSNAPS are off, then the LISP with store them as being off, then shut them off (even though they are off), then restore them to they're previous off mode.***

EDIT: Re-read your post and edited accordingly...


&#40;defun c&#58;brr &#40;/ osn p1 p2 p3 p4 p5 p5a p6 d1 d2 d4 dd2 api a1 a2 a3 &#41;
&#40;setq osn &#40;getvar "osmode"&#41;&#41;
&#40;setq p1 &#40;getpoint "\n First point&#58; "&#41;&#41;
&#40;setq p2 &#40;getpoint p1 "\n Second point&#58;"&#41;&#41;
&#40;setvar "osmode" 0&#41;
&#40;command "line" p1 p2 ""&#41;
&#40;setq d1 &#40;distance p1 p2&#41;&#41;
&#40;setq d2 &#40;* d1 0.1&#41;&#41;;=== change the number in this line to adjust the size of zig-zag
&#40;setq api &#40;/ pi 180&#41;&#41;
&#40;setq a1 &#40;angle p1 p2&#41;&#41;
&#40;setq a2 &#40;+ a1 &#40;* api 63&#41;&#41;&#41;
&#40;setq p3 &#40;polar p2 a2 d2&#41;&#41;
&#40;setq a3 &#40;+ a1 &#40;* api 284&#41;&#41;&#41;
&#40;setq dd2 &#40;* d2 &#40;sin &#40;* api 63&#41;&#41;&#41;&#41;
&#40;setq d3 &#40;/ &#40;* dd2 2&#41; &#40;cos &#40;* api 14&#41;&#41;&#41;&#41;
&#40;setq p4 &#40;polar p3 a3 d3&#41;&#41;
&#40;setq p5 &#40;polar p4 a2 d2&#41;&#41;
&#40;setvar "osmode" osn&#41;
&#40;setq p5a &#40;getpoint p5 "\n Third point&#58;"&#41;&#41;
&#40;setvar "osmode" 0&#41;
&#40;setq d4 &#40;distance p5 p5a&#41;&#41;
&#40;setq p6 &#40;polar p5 a1 d4&#41;&#41;
&#40;command "line" "" p3 p4 p5 p6 ""&#41;
&#40;setvar "osmode" osn&#41;
&#40;princ&#41;
&#41;
&#40;princ "\n Type < brr > to draw Breakline Symbol&#58; "&#41;

Cadastrophic
3rd Nov 2004, 08:32 am
:D Thanks. Works just fine now.

Dommy2Hotty
3rd Nov 2004, 04:45 pm
:D Thanks. Works just fine now.

No problem :twisted:

paulmcz
31st Dec 2004, 02:07 am
I don't get it. Why would the routine turn your osnap off? It never happens to me whenever I use it. I know, there is no error checking in it but you'd have to cancel (Esc) in the middle of it to trigger the error. Is that what you sometimes do?

Cadastrophic
31st Dec 2004, 02:19 am
I don't know why it happens. The routine posted above sorted the problem out, but as of yesterday, a similar problem has cropped up: When completing the line command or changing views, osnap will sometimes turn itself off. Damned annoying!

paulmcz
31st Dec 2004, 02:47 am
I wrote the routine some 3 years ago and later, I uploaded it to CADdepot but before that, I tested it in R14 through 2004. Whether "osn" is or isn't declared local variable, shouldn't make any difference. It doesn't when I use the routine.
Apparently, you have some other problem, which is causing your osnap to go off. Once you fix it, I'd like to know what the problem was and how you fixed it.
Please, let me know.
Thanks, Paul.

Cadastrophic
31st Dec 2004, 02:58 am
As my name suggests, I'm not the top officinado of AutoCAD. I wouldn't have a clue where to start looking for the osnap problem let alone know how to fix it. :huh:
Any tips? o:)

paulmcz
31st Dec 2004, 03:05 am
Do you use many LISPs?
If you do, do you have them loaded through acaddoc.lsp or acad.lsp?
What is your Acad version/Windows?

Cadastrophic
31st Dec 2004, 03:15 am
I am currently on Win 2000 and ACAD 2000 and use many lisps, but I don't load them through acaddoc.lsp or acad.lsp. I do have them in a common folder in the search path though.
I'm working in ACAD at the moment (between posting here at any rate!), and am not currently using any lisps, just the standard buttons/inputs and the osnap keeps going off.
I'd bet if I rebooted my puter and went and got some lunch, the problem would have fixed itself for a while. I'm not sure what triggers the problem. I'll try and be aware of what I'm doing when it happens again.
I'll just reboot now.

paulmcz
31st Dec 2004, 03:42 am
It must be some of the customization you have on your setup.
Other than that, I have no clue. You just have to watch it and one day, you'll find out. I'd still like to know your findings, if any.
Good luck and bonne appetit.

Cadastrophic
31st Dec 2004, 03:56 am
Thanks for you input. I'll post on this thread if I learn any more about it.
Mmmmmmm! Yummy Thai red beef curry and noodles!

Cadastrophic
31st Dec 2004, 10:08 pm
Do you use many LISPs?
If you do, do you have them loaded through acaddoc.lsp or acad.lsp?

Would it be best to load all my lisps into one of the above files or is it OK just to put them in a folder in the search path?

paulmcz
1st Jan 2005, 03:25 pm
Would it be best to load all my lisps into one of the above files or is it OK just to put them in a folder in the search path?

As long as they get loaded, It shouldn't make any difference, where you store your lisp routines, or which way you load them. acaddoc.lsp gets loaded and executed with every drawing you open, so if you have a function there causing the problem, you can get rid of it. Try to disable one at the time and see if it fixes the problem. I only have "load calls" for the routines, I want to have instant access to in that file.
Also, I've read somewhere, that redefined acad commands could also cause all kinds of unpredictable behaviour.

Fantomas
2nd Jan 2005, 06:19 pm
As my name suggests, I'm not the top officinado of AutoCAD. I wouldn't have a clue where to start looking for the osnap problem let alone know how to fix it.
Any tips?
>Cadastrophic
Not only pressing Esc but also other reasons can influence a stop of the program. For guaranteed restoration of an environment it is necessary to use the built - in function *error*. Data on last error contain in system variable ERRNO which for AutoCAD 2004 can accept 105 various values.

Also, I've read somewhere, that redefined acad commands could also cause all kinds of unpredictable behaviour.
>paulmcz
Always type COMMAND with modifiers "_" and "." . For example (command "_.line" ... The modifier "." allows to cause an original command irrespective of its redefinition in ACAD.PGP. The modifier "_" allows to cause an original English-speaking command even if the user works in located (the German, French version etc.). A call of options also it is necessary to do names with this modifier. For example (COMMAND " _ .ERASE " "_A" " ").

paulmcz
3rd Jan 2005, 05:21 pm
You learn something new every day!
thanks Fantomas