PDA

View Full Version : Slow down of Lisp Routines



spencer.67965
2006-01-10, 11:17 PM
Since I switched to ADT 2006 I have noticed a slow down in my lisp routines that work great in AutoCAD 2005.

Here is the code and below is an example what it does in the AutoCAD Text Window.

Any help would be nice.

Thanks



;Shear-Wall Hold-Down "A" "SW1"
(Defun c:dda1 (/ msg os cl style P1 P2 P3 angs ang c1 c2 t1 t2 cc1 cc2 tt1 tt2 lay add s1 s2 s3 *error*)

;Begin Undo Mark
(command "undo" "begin" "")
;Begin Error handleing
(defun *error* (msg)
(princ "error: ")
(princ msg)
(command "osmode" os)
(command "clayer" cl)(TERPRI)
(command "textstyle" style)(TERPRI)
(PRINC "LAYERS, TEXT STYLE, AND OSNAPS RETURNED TO ORIGIONAL SETTINGS.")(TERPRI)
(princ)
(command "undo" "end" "")
(command "undo" "1")
(PRINC "ROUTINE TERMINATED.")(TERPRI)
(exit)
)
;DEGREES TO RADIANS PROGRAM

(DEFUN DTR (A)(* pi ( / A 180.0)))
;END DEGREES TO RADIANS

;RADIANS TO DEGREES PROGRAM

(DEFUN RTD (A)(/ (* A 180.0) pi))
;END RADIANS TO DEGREES PROGRAM
;SAVE CURRENT LAYER AND OSNAP VALUES

(setq cl (getvar "clayer"))
(setq os (getvar "osmode"))
(setq style (getvar "textstyle"))
;END SAVE CURRENT LAYER AND OSNAP VALUES
;LAYERS SETUP

(command "clayer" "ACUTEENG")

;ENDLAYER SETUP

;BEGIN USER INPUT

(command "osmode" "1")(terpri)
(setq p1 (getpoint "FIRST CORNER (P1): "))(terpri)
(setq p2 (getpoint "SECOND CORNER (P2): "))(terpri)
(command "osmode" "514")(terpri)
(setq p3 (getpoint "INSERTION POINT (P3): "))(terpri)

;END USER INPUT
;Begin Hold-Down Section
(command "osmode" "0")
(setq angs (angle p1 p2))
(setq ang (- angs (DTR 90)))

(setq c1 (polar p1 ang 8.0))
(setq c2 (polar p1 ang 12.0))

(setq t1 (polar c2 angs 6.0))
(setq t2 (polar c2 angs -6.0))
(setq cc1 (polar p2 ang 8.0))
(setq cc2 (polar p2 ang 12.0))

(setq tt1 (polar cc2 angs 6.0))
(setq tt2 (polar cc2 angs -6.0))

(setq lay (getvar "clayer"))
(setq add 180)
(IF (AND (<= angs (dtr 270)) (> angs (dtr 90))) (setq add 0))

(command "osmode" 0)
(command "clayer" "acuteeng")
(command "pline" p1 t1 t2 "c")
(command "pline" p2 tt1 tt2 "c")
(command "textstyle" "swacute" "")
(command "text" "j" "mc" c1 (+ add (rtd (- ang (dtr 90)))) "A" "")
(command "text" "j" "mc" cc1 (+ add (rtd (- ang (dtr 90)))) "A" "")
;End Hold-Down Section
;Begin Shear-Wall Section

(setq s1 (polar p3 ang 12.0))
(setq s2 (polar p3 ang 18.0))
(setq s3 (polar S1 angs 12.0))
(setq add 0)
(IF (AND (<= angs (dtr 270)) (> angs (dtr 90))) (setq add 180))
(command "osmode" 0)
(command "clayer" "acuteeng")
(command "ellipse" "c" s1 s3 s2)
(command "textstyle" "swacute" "")
(command "text" "j" "mc" s1 (+ add (rtd angs)) "SW1" "" "")
;End Shear-Wall Section

;RETURN OSNAPS AND LAYER TO NORMAL END PROGRAM
(command "osmode" os)
(command "clayer" cl)(TERPRI)
(command "textstyle" style)(TERPRI)
(PRINC "LAYERS, TEXT STYLE, AND OSNAPS RETURNED TO ORIGIONAL SETTINGS.")(TERPRI)
(PRINC "SHEAR WALL FINISHED.")(TERPRI)(princ)
(command "undo" "end" "")(princ)
;OSNAPS AND LAYER AND RETURNED TO NORMAL
)
;END Shear-Wall Hold-Down "A" "SW1"


AutoCAD Text Window Output


Command: DDA1 Unknown command "DDA1". Press F1 for help.
FIRST CORNER (P1): SECOND CORNER (P2): INSERTION POINT (P3): Unknown command
"DDA1". Press F1 for help.
Unknown command "DDA1". Press F1 for help.
Unknown command "DDA1". Press F1 for help.
Unknown command "DDA1". Press F1 for help.
Unknown command "DDA1". Press F1 for help.
Unknown command "DDA1". Press F1 for help.
LAYERS, TEXT STYLE, AND OSNAPS RETURNED TO ORIGIONAL SETTINGS.
SHEAR WALL FINISHED.
Unknown command "DDA1". Press F1 for help.
nil

T.Willey
2006-01-11, 12:00 AM
Most of the time when I see this, is that there are too many double quotes (""). The first one I see is the undo begin. Yours has an extra one in it. I don't have time to look through the whole code, but this might be what you need to correct.

kennet.sjoberg
2006-01-11, 12:06 AM
...mmmm, there is some work to do in the code for you.

(command "clayer" "ACUTEENG") ;; <-- do the layer exist ? priority low
(command "clayer" "acuteeng") ;; <-- do the layer exist ? priority low
(command "textstyle" "swacute" "") ;; <-- do the textstyle exist ? priority medium
(command "text" "j" "mc" . . . . . ;; <-- does this work ? priority high

: ) Happy Computing !

kennet

spencer.67965
2006-01-11, 03:36 PM
Most of the time when I see this, is that there are too many double quotes (""). The first one I see is the undo begin. Yours has an extra one in it. I don't have time to look through the whole code, but this might be what you need to correct.
It looks like it has to do with the double quotes. The only problem is that I have over 200 of these routines I need to fix. I guess I'll be using search and replace alot.

Thanks


...mmmm, there is some work to do in the code for you.

(command "clayer" "ACUTEENG") ;; <-- do the layer exist ? priority low
(command "clayer" "acuteeng") ;; <-- do the layer exist ? priority low
(command "textstyle" "swacute" "") ;; <-- do the textstyle exist ? priority medium
(command "text" "j" "mc" . . . . . ;; <-- does this work ? priority high

: ) Happy Computing !
This works just fine. I always run a different routine that sets up my drawing with the appropriate layers and text styles. I like it when the routine crashes it reminds me to run my setup routine, but thanks for the input, it was appreciated.

kennet.sjoberg
2006-01-11, 04:14 PM
. . . I have over 200 of these routines I need to fix . . .
Multiple files ? TextPad is a monster to do that.

: ) Happy Computing !

kennet