TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TimSpangler on November 01, 2006, 12:19:26 PM
-
My company has a little program to draw xline for construction lines. It works ok but there is a little problem.
If you want to draw more than 2 line it resets the layer.
;;; ------------------------------------------------------------------------
(defun c:XLH (/)
;;; Begin Error Handler -------------------------------------------------
(defun *error* (MSG)
(if (not (member MSG '("Function cancelled" "quit / exit abort")))
(princ (strcat "\n*** Program Error: " (strcase MSG) " ***"))
(princ "\n... Program Cancelled ...")
)
(while (< 0 (getvar "cmdactive"))
(command)
)
(setvar "CLAYER" OldClayer)
(setvar "CMDECHO" OldCmdEcho)
(princ)
)
;;; End Error Handler ---------------------------------------------------
(setq OldClayer (getvar "CLAYER"))
(setq OldCmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(if (tblsearch "Layer" "51")
(setvar "CLAYER" "51")
)
(command "xline" "hor" pause)
(setvar "CLAYER" OldClayer)
(setvar "CMDECHO" OldCmdEcho)
(princ)
)
Here is the code. What I need is for the program to continue with the correct layer until the user ends the program. This doesn't seem to be working.
Thanks all
-
Give this a shot.... Note the 3 lines after (command "xline" "hor" pause)
;;; ------------------------------------------------------------------------
(defun c:XLH (/)
;;; Begin Error Handler -------------------------------------------------
(defun *error* (MSG)
(if (not (member MSG '("Function cancelled" "quit / exit abort")))
(princ (strcat "\n*** Program Error: " (strcase MSG) " ***"))
(princ "\n... Program Cancelled ...")
)
(while (< 0 (getvar "cmdactive"))
(command)
)
(setvar "CLAYER" OldClayer)
(setvar "CMDECHO" OldCmdEcho)
(princ)
)
;;; End Error Handler ---------------------------------------------------
(setq OldClayer (getvar "CLAYER"))
(setq OldCmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(if (tblsearch "Layer" "51")
(setvar "CLAYER" "51")
)
(command "xline" "hor" pause)
(while (> (getvar "cmdactive") 0)
(command pause)
)
(setvar "CLAYER" OldClayer)
(setvar "CMDECHO" OldCmdEcho)
(princ)
)
-
Actually, the PAUSE in (command "xline" "hor" pause) is not necessary.
-
That works but not exactly what I was looking for.
( actually used that first only slightly differant)
(while (< 0 (getvar "cmdactive"))
(command)
)
But what I would like is to stay in the xline command until the user wants to exit,while still maintaining the correct layer.
-
I use this (no error check):
(defun C:Gb_CV ()(Gb_CL "v"))
(defun C:Gb_CH ()(Gb_CL "h"))
(defun Gb_CL (richting / oudlaag)
(setq oudlaag (getvar "CLAYER"))
(c:Gb_HULPL); Make and set layer
(command "_.xline" richting (while (= (logand (getvar "CMDACTIVE") 1) 1)(command PAUSE)))
(setvar "CLAYER" oudlaag)
(princ)
)
-
Crank that did the trick.
Thanks man.
(I'll have to add that to my bag'o tricks)