Routine not completing as directed

Mark Godfrey

Usenet Archive
Joined
Jul 14, 2003
Messages
13
Reaction score
0
Not sure if this routine is for drawings that only has a dimsclae of 1. The drawing I am trying to use this in has a dimscale of 40 and when I invoke the command it asks me all the correct procedures, but then stops with this:
"Command: 40.000000" Any ideas of why this is doing this and how to fix it?
The code is below:

(defun c:smb (/ att om scl p1 p2 p3 p1x p1y p2x p2y p3x p3y blk leg) (setq att (getvar "attdia")) (setvar "attdia" 1) (setq om (getvar "orthomode")) (setvar "orthomode" 1) (setq scl (getvar "dimscale")) ;................................................................... (setq p1 (getpoint "\nIsertion point of Section Cut: ")) (if (= p1 nil)(exit)) (setq p2 (getpoint p1 "\nDirection of Section Cut: ")) (if (= p2 nil)(exit)) (setq p3 (getpoint p1 "\nLocation of Section Cut End: ")) (if (= p3 nil)(exit)) ;.................................................................... (setq p1x (car p1)) (setq p1y (car (cdr p1))) (setq p2x (car p2)) (setq p2y (car (cdr p2))) (setq p3x (car p3)) (setq p3y (car (cdr p3))) ;.................................................................... (if (and (= p1x p2x) (> p2y p1y) ) (progn (setq blk "b-cut-u") (cond ((> p3x p1x)(setq leg "bxend-u1")) ((< p3x p1x)(setq leg "bxend-u2")) ) ) ) ;.................................................................... (if (and (= p1x p2x) (< p2y p1y) ) (progn (setq blk "b-cut-d") (cond ((> p3x p1x)(setq leg "bxend-d1")) ((< p3x p1x)(setq leg "bxend-d2")) ) ) ) ;.................................................................... (if (and (= p1y p2y) (< p2x p1x) ) (progn (setq blk "b-cut-l") (cond ((> p3y p1y)(setq leg "bxend-l2")) ((< p3y p1y)(setq leg "bxend-l1")) ) ) ) ;.................................................................... (if (and (= p1y p2y) (> p2x p1x) ) (progn (setq blk "b-cut-r") (cond ((> p3y p1y)(setq leg "bxend-r2")) ((< p3y p1y)(setq leg "bxend-r1")) ) ) ) ;.................................................................... (command "insert" blk p1 scl scl "") (command "insert" leg p3 scl scl "")

;.................................................................... (setvar "orthomode" om) (setvar "attdia" att) (princ)
)
 
Modify as shown:

(command "._insert" blk "_non" p1 scl scl "")
(command "._insert" leg "_non" p3 scl scl "")

Running OSnaps wreaking havoc, I suspect.

--
R. Robert Bell, MCSE
www.AcadX.com

| Not sure if this routine is for drawings that only has a dimsclae of 1. The | drawing I am trying to use this in has a dimscale of 40 and when I invoke | the command it asks me all the correct procedures, but then stops with this:
| "Command: 40.000000" Any ideas of why this is doing this and how to fix it? | The code is below:
|
| (defun c:smb (/ att om scl p1 p2 p3 p1x p1y p2x p2y p3x p3y blk leg) | (setq att (getvar "attdia")) | (setvar "attdia" 1) | (setq om (getvar "orthomode")) | (setvar "orthomode" 1) | (setq scl (getvar "dimscale")) | ;................................................................... | (setq p1 (getpoint "\nIsertion point of Section Cut: ")) | (if (= p1 nil)(exit)) | (setq p2 (getpoint p1 "\nDirection of Section Cut: ")) | (if (= p2 nil)(exit)) | (setq p3 (getpoint p1 "\nLocation of Section Cut End: ")) | (if (= p3 nil)(exit)) | ;.................................................................... | (setq p1x (car p1)) | (setq p1y (car (cdr p1))) | (setq p2x (car p2)) | (setq p2y (car (cdr p2))) | (setq p3x (car p3)) | (setq p3y (car (cdr p3))) | ;.................................................................... | (if | (and | (= p1x p2x) | (> p2y p1y) | ) | (progn | (setq blk "b-cut-u") | (cond | ((> p3x p1x)(setq leg "bxend-u1")) | ((< p3x p1x)(setq leg "bxend-u2")) | ) | ) | ) | ;.................................................................... | (if | (and | (= p1x p2x) | (< p2y p1y) | ) | (progn | (setq blk "b-cut-d") | (cond | ((> p3x p1x)(setq leg "bxend-d1")) | ((< p3x p1x)(setq leg "bxend-d2")) | ) | ) | ) | ;.................................................................... | (if | (and | (= p1y p2y) | (< p2x p1x) | ) | (progn | (setq blk "b-cut-l") | (cond | ((> p3y p1y)(setq leg "bxend-l2")) | ((< p3y p1y)(setq leg "bxend-l1")) | ) | ) | ) | ;.................................................................... | (if | (and | (= p1y p2y) | (> p2x p1x) | ) | (progn | (setq blk "b-cut-r") | (cond | ((> p3y p1y)(setq leg "bxend-r2")) | ((< p3y p1y)(setq leg "bxend-r1")) | ) | ) | ) | ;.................................................................... | (command "insert" blk p1 scl scl "") | (command "insert" leg p3 scl scl "") | | ;.................................................................... | (setvar "orthomode" om) | (setvar "attdia" att) | (princ) | ) | |
 
That did the trick. Could you please tell me what prompted you to think it was that and how did that fix do the trick? Thank ever so much.
 
Actually, the problem still exists in the one drawing and I am not sure why. The only difference between the 2 drawings right off hand is that the one that is having the difficulty has an xref insterted into it and has multiple layouts. Both drawings that I am working with have a dimscale of 40, so this doesn't make sense. The one that it does work in is actually the xref for the other drawing. Any other ideas? Should I email you the 2 drawings?
Thanks.
 
Damn, now it is doing it in both drawings and I am not sure why. I haven't done anything diiferent except use this routine:

;========================================================================= ; SNAPLINE.lsp Snapang match line (Command function for AutoCAD) ; (c) Copyright 2001 TimeSavers for CAD ; from: www.timesaversforcad.com ;------------------------------------------------------------------------- ; Description:
;
; Sets SNAPANG to angle of selected LINE, LWPOLYLINE, POLYLINE, XLINE ; or LEADER segment. Works for subentities (nested in BLOCK or XREF) ; as well. ; ; To run transparent, first place contents below in ACAD.LSP or ; <menu>.MNL to preload, then assign to a toolbar button or pulldown ; in your <menu>.MNU file:
; ^P'snapline
; Works only for native AutoCAD commands, not AutoLISP commands. ;========================================================================= (defun c:snapline (/ a)(if (setq a (linang))(setvar "snapang" a))(princ)) ;-GET ANGLE OF LINE SEGMENT (defun linang (/ *la:err* dtor e et ed p1 p2 aptr l_ang) ;-ERROR HANDLING (defun *la:err* (m) (or (member m '("Function cancelled" "quit / exit abort" "console break")) (prompt (strcat "\n< " m " >\n")) ) (if aptr (setvar "aperture" aptr))(setq *error* *e*)(princ) ) ;-DEGREES TO RADIANS (defun dtor (d)(/ (* d pi) 180.0))

;-GET VALUES
(setq *e* (cond (*e*)(*error*))
*error* *la:err*
)

;-ACTUAL FUNCTION
(if (or (while (progn (initget "0 A ")
(setq ne (nentsel "\n0/Angle/<Select line segment>:
"))
(cond ((not ne)(princ "0 found"))
((= ne "0")(setq l_ang 0) nil)
((= ne "A")(not (setq l_ang (getangle
"\nAngle: "))))
((listp ne)
(setq e (car ne)
ed (entget e)
et (cdr (assoc 0 ed))
)
(if (not (wcmatch et
"*LINE,VERTEX,LEADER,HATCH"))
(princ "Invalid object, Try Again ")
)
)
)
)
)
(/= ne "")
)
(or l_ang
(progn
(setq aptr (getvar "aperture"))
(setvar "aperture" (getvar "pickbox"))
(setq p1 (osnap (cadr ne) "nea")
p2 (osnap (cadr ne) "mid")
l_ang (angle p1 p2)
)
(setvar "aperture" aptr)
)
)
)

(setq *error* *e*)
l_ang
)
;-END FILE

I do know what difference this would have made. This is really starting to get on my nerves. Please help. Thanks.
 
One last note, it still works in PS for both drawings, but not in model space. Pretty weird problem.
 
You may email me the two drawings (zipped). Just remove the obvious spam filter from my reply address.

--
R. Robert Bell, MCSE
www.AcadX.com

| One last note, it still works in PS for both drawings, but not in model | space. Pretty weird problem. | | > Modify as shown:
| >
| > (command "._insert" blk "_non" p1 scl scl "")
| > (command "._insert" leg "_non" p3 scl scl "")
| >
| > Running OSnaps wreaking havoc, I suspect.
| >
| > --
| > R. Robert Bell, MCSE
| > www.AcadX.com
| >
| >
| > | > | Not sure if this routine is for drawings that only has a dimsclae of
1.
| > The
| > | drawing I am trying to use this in has a dimscale of 40 and when I | invoke | > | the command it asks me all the correct procedures, but then stops with | > this:
| > | "Command: 40.000000" Any ideas of why this is doing this and how to fix | > it? | > | The code is below:
| > |
| > | (defun c:smb (/ att om scl p1 p2 p3 p1x p1y p2x p2y p3x p3y blk leg) | > | (setq att (getvar "attdia")) | > | (setvar "attdia" 1) | > | (setq om (getvar "orthomode")) | > | (setvar "orthomode" 1) | > | (setq scl (getvar "dimscale")) | > | ;................................................................... | > | (setq p1 (getpoint "\nIsertion point of Section Cut: ")) | > | (if (= p1 nil)(exit)) | > | (setq p2 (getpoint p1 "\nDirection of Section Cut: ")) | > | (if (= p2 nil)(exit)) | > | (setq p3 (getpoint p1 "\nLocation of Section Cut End: ")) | > | (if (= p3 nil)(exit)) | > | ;.................................................................... | > | (setq p1x (car p1)) | > | (setq p1y (car (cdr p1))) | > | (setq p2x (car p2)) | > | (setq p2y (car (cdr p2))) | > | (setq p3x (car p3)) | > | (setq p3y (car (cdr p3))) | > | ;.................................................................... | > | (if | > | (and | > | (= p1x p2x) | > | (> p2y p1y) | > | ) | > | (progn | > | (setq blk "b-cut-u") | > | (cond | > | ((> p3x p1x)(setq leg "bxend-u1")) | > | ((< p3x p1x)(setq leg "bxend-u2")) | > | ) | > | ) | > | ) | > | ;.................................................................... | > | (if | > | (and | > | (= p1x p2x) | > | (< p2y p1y) | > | ) | > | (progn | > | (setq blk "b-cut-d") | > | (cond | > | ((> p3x p1x)(setq leg "bxend-d1")) | > | ((< p3x p1x)(setq leg "bxend-d2")) | > | ) | > | ) | > | ) | > | ;.................................................................... | > | (if | > | (and | > | (= p1y p2y) | > | (< p2x p1x) | > | ) | > | (progn | > | (setq blk "b-cut-l") | > | (cond | > | ((> p3y p1y)(setq leg "bxend-l2")) | > | ((< p3y p1y)(setq leg "bxend-l1")) | > | ) | > | ) | > | ) | > | ;.................................................................... | > | (if | > | (and | > | (= p1y p2y) | > | (> p2x p1x) | > | ) | > | (progn | > | (setq blk "b-cut-r") | > | (cond | > | ((> p3y p1y)(setq leg "bxend-r2")) | > | ((< p3y p1y)(setq leg "bxend-r1")) | > | ) | > | ) | > | ) | > | ;.................................................................... | > | (command "insert" blk p1 scl scl "") | > | (command "insert" leg p3 scl scl "") | > | | > | ;.................................................................... | > | (setvar "orthomode" om) | > | (setvar "attdia" att) | > | (princ) | > | ) | > | | > | | > | > | |
 
Running OSnaps throw many old lisp routines off. I think this issue alone has generated at least 50% of the migration issues related to AutoLISP in this ng.

You can enter the "NONe" osnap override at any pick prompt. It is a one-time only override, so it doesn't affect your current running OSnaps permanently.

(Of course, you have other issues too... <vbg> see reply below)
 
There were rounding errors. The routine is buggy enough that if the point equality test fails, no block name is set. I didn't take the time to fully optimize it, but did get the band-aids in where I indicated. BTW, you failed to send the library blocks themselves, but I think I got it for you.

(defun c:smb (/ att om scl p1 p2 p3 p1x p1y p2x p2y p3x p3y blk leg) (setq att (getvar "attdia")) (setvar "attdia" 1) (setq om (getvar "orthomode")) (setvar "orthomode" 1) (setq scl (getvar "dimscale")) ;................................................................... (setq p1 (getpoint "\nIsertion point of Section Cut: ")) (if (= p1 nil)(exit)) (setq p2 (getpoint p1 "\nDirection of Section Cut: ")) (if (= p2 nil)(exit)) (setq p3 (getpoint p1 "\nLocation of Section Cut End: ")) (if (= p3 nil)(exit)) ;.................................................................... (setq p1x (car p1)) (setq p1y (car (cdr p1))) (setq p2x (car p2)) (setq p2y (car (cdr p2))) (setq p3x (car p3)) (setq p3y (car (cdr p3))) ;.................................................................... (if (and (equal p1x p2x 1e-6) ; <- changed here (> p2y p1y) ) (progn (setq blk "b-cut-u") (cond ((> p3x p1x)(setq leg "bxend-u1")) ((< p3x p1x)(setq leg "bxend-u2")) ) ) ) ;.................................................................... (if (and (equal p1x p2x 1e-6) ; <- changed here (< p2y p1y) ) (progn (setq blk "b-cut-d") (cond ((> p3x p1x)(setq leg "bxend-d1")) ((< p3x p1x)(setq leg "bxend-d2")) ) ) ) ;.................................................................... (if (and (equal p1y p2y 1e-6) ; <- changed here (< p2x p1x) ) (progn (setq blk "b-cut-l") (cond ((> p3y p1y)(setq leg "bxend-l2")) ((< p3y p1y)(setq leg "bxend-l1")) ) ) ) ;.................................................................... (if (and (equal p1y p2y 1e-6) ; <- changed here (> p2x p1x) ) (progn (setq blk "b-cut-r") (cond ((> p3y p1y)(setq leg "bxend-r2")) ((< p3y p1y)(setq leg "bxend-r1")) ) ) ) ;.................................................................... (command "._insert" blk "_non" p1 scl scl "") ; <- changed here (command "._insert" leg "_non" p3 scl scl "") ; <- changed here

;.................................................................... (setvar "orthomode" om) (setvar "attdia" att) (princ)
)

--
R. Robert Bell, MCSE
www.AcadX.com

| You may email me the two drawings (zipped). Just remove the obvious spam | filter from my reply address. | | -- | R. Robert Bell, MCSE | www.AcadX.com | | | | | One last note, it still works in PS for both drawings, but not in model | | space. Pretty weird problem. | | | | > Modify as shown:
| | >
| | > (command "._insert" blk "_non" p1 scl scl "")
| | > (command "._insert" leg "_non" p3 scl scl "")
| | >
| | > Running OSnaps wreaking havoc, I suspect.
| | >
| | > --
| | > R. Robert Bell, MCSE
| | > www.AcadX.com
| | >
| | >
| | > | | > | Not sure if this routine is for drawings that only has a dimsclae of | 1. | | > The | | > | drawing I am trying to use this in has a dimscale of 40 and when I | | invoke | | > | the command it asks me all the correct procedures, but then stops with | | > this:
| | > | "Command: 40.000000" Any ideas of why this is doing this and how to | fix | | > it? | | > | The code is below:
| | > |
| | > | (defun c:smb (/ att om scl p1 p2 p3 p1x p1y p2x p2y p3x p3y blk leg) | | > | (setq att (getvar "attdia")) | | > | (setvar "attdia" 1) | | > | (setq om (getvar "orthomode")) | | > | (setvar "orthomode" 1) | | > | (setq scl (getvar "dimscale")) | | > | ;................................................................... | | > | (setq p1 (getpoint "\nIsertion point of Section Cut: ")) | | > | (if (= p1 nil)(exit)) | | > | (setq p2 (getpoint p1 "\nDirection of Section Cut: ")) | | > | (if (= p2 nil)(exit)) | | > | (setq p3 (getpoint p1 "\nLocation of Section Cut End:
"))
| | > | (if (= p3 nil)(exit))
| | > |
;.................................................................... | | > | (setq p1x (car p1)) | | > | (setq p1y (car (cdr p1))) | | > | (setq p2x (car p2)) | | > | (setq p2y (car (cdr p2))) | | > | (setq p3x (car p3)) | | > | (setq p3y (car (cdr p3))) | | > | ;.................................................................... | | > | (if | | > | (and | | > | (= p1x p2x) | | > | (> p2y p1y) | | > | ) | | > | (progn | | > | (setq blk "b-cut-u") | | > | (cond | | > | ((> p3x p1x)(setq leg "bxend-u1")) | | > | ((< p3x p1x)(setq leg "bxend-u2")) | | > | ) | | > | ) | | > | ) | | > | ;.................................................................... | | > | (if | | > | (and | | > | (= p1x p2x) | | > | (< p2y p1y) | | > | ) | | > | (progn | | > | (setq blk "b-cut-d") | | > | (cond | | > | ((> p3x p1x)(setq leg "bxend-d1")) | | > | ((< p3x p1x)(setq leg "bxend-d2")) | | > | ) | | > | ) | | > | ) | | > | ;.................................................................... | | > | (if | | > | (and | | > | (= p1y p2y) | | > | (< p2x p1x) | | > | ) | | > | (progn | | > | (setq blk "b-cut-l") | | > | (cond | | > | ((> p3y p1y)(setq leg "bxend-l2")) | | > | ((< p3y p1y)(setq leg "bxend-l1")) | | > | ) | | > | ) | | > | ) | | > | ;.................................................................... | | > | (if | | > | (and | | > | (= p1y p2y) | | > | (> p2x p1x) | | > | ) | | > | (progn | | > | (setq blk "b-cut-r") | | > | (cond | | > | ((> p3y p1y)(setq leg "bxend-r2")) | | > | ((< p3y p1y)(setq leg "bxend-r1")) | | > | ) | | > | ) | | > | ) | | > | ;.................................................................... | | > | (command "insert" blk p1 scl scl "") | | > | (command "insert" leg p3 scl scl "") | | > | | | > | ;.................................................................... | | > | (setvar "orthomode" om) | | > | (setvar "attdia" att) | | > | (princ) | | > | ) | | > | | | > | | | > | | > | | | | | |
 

Latest threads

Back
Top