Trying to create 2 lines, but
Short version:I have a code that uses 4 commands to create 4 different lines. However, even if the points i give him are different, he sometimes places the lines over themselves.
I have used a prin1 to confirm the points i give him are really different, and they are, but for some reason the code places the lines over themselves randomly!
Long version: the code
(defun c:fuste8 (/ pin altura dsup dinf nlados esp e2 ss1 p1esq p2esq p1dir p2dir p1esq1 p2esq1 p1dir1 p2dir1 jorr lest ldir dirint esqint teste dinttopo dintbase aitopo aibase)(setq pin (getpoint "\nPonto de introducao: "))(setq altura (getint "\nAltura: ")dsup (getint "\nDiametro superior: ")dinf (getint "\nDiametro inferior: ");nlados (getint "\nNumero de lados: ")esp (getint "\nEspessura: ")jorr (/ (* (atan (- (/ dinf 2) (/ dsup 2)) altura) 180) PI));;DADOS COMPLEMENTARES(setq dinttopo (- dsup esp)dintbase (- dinf esp))(setqaitopo (* dinttopo (/ (sin (/ PI ) (cos (/ PI )))aibase (* dintbase (/ (sin (/ PI ) (cos (/ PI ))));;Linhas extremas(setq p1esq (cons (- (car pin) (/ dsup 2)) (cons (cadr pin) (cons 0.0 '()))))(setq p2esq (cons (- (car pin) (/ dinf 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))))(setq p1dir (cons (+ (car pin) (/ dsup 2)) (cons (cadr pin) (cons 0.0 '()))))(setq p2dir (cons (+ (car pin) (/ dinf 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))))(command "line" p2esq p1esq "") ;(setq lest (entlast));(command "offset" esp lest p1dir "");(setq esqint (entlast))(command "line" p2dir p1dir "") ;(setq ldir (entlast));(command "offset" esp ldir p1esq "");(setq dirint (entlast));;Linha intermedia de 8(setq p1esq1 (cons (- (car pin) (/ aitopo 2)) (cons (cadr pin) (cons 0.0 '()))))(setq p2esq1 (cons (- (car pin) (/ aibase 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))))(setq p1dir1 (cons (+ (car pin) (/ aitopo 2)) (cons (cadr pin) (cons 0.0 '()))))(setq p2dir1 (cons (+ (car pin) (/ aibase 2)) (cons (- (cadr pin) altura) (cons 0.0 '()))));;THESE LINES OVERLAP THE PREVIOUS ONES!(command "line" p1esq1 p2esq1 "") (command "line" p1dir1 p2dir1 "") (prin1 p2esq1)(prin1 " ")(prin1 p2esq)(prin1 " ")(prin1 p1esq1)(prin1 " ")(prin1 p1esq) Sounds like object snap is enabled while the routine is running. you are absolutely right.. is it possible to disable osnap and re-enable it at the end of the routine? (setq osnapmode (getvar 'osmode)) ;this saves your current osnap settings
(setvar 'osmode 0) ;this turns off osnaps
; **your routine here
(setvar 'osmode osnapmode) ;this resets to your saved osnap settings Thank you very much everyone A bit more on osmode sometimes in a lisp you want certain snaps and do not want operator to use wrong ones so you just set your snaps to what you want then type osmode the number shown matches that combination. eg our normal working is osmode 47. (command "line" "non"p1esq1 "non"p2esq1 "") (command "line" "non"p1dir1 "non"p2dir1 "")
Put 'non"before the point Yes, using osmode (value) seems pretty nice. But i've ran into other problem, if for some reason i cancel the code mid-execution, osnap will stay at 0. Is it possible to replace osmode back to the saved value if the user presses "esc"?
I might use "non", but i'm curious if a action on escape is possible with lisp
Read post #7 in this thread: http://www.cadtutor.net/forum/showthread.php?98546-Lisp-circle @Grrr
I've read the post, what's new about it?
页:
[1]
2