TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TimSpangler on November 01, 2006, 12:19:26 PM

Title: Xline help
Post 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.

Code: [Select]
;;; ------------------------------------------------------------------------
(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
Title: Re: Xline help
Post by: Guest on November 01, 2006, 12:24:50 PM
Give this a shot.... Note the 3 lines after (command "xline" "hor" pause)

Code: [Select]
;;; ------------------------------------------------------------------------
(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)
)
Title: Re: Xline help
Post by: Guest on November 01, 2006, 12:26:38 PM
Actually, the PAUSE in (command "xline" "hor" pause) is not necessary.
Title: Re: Xline help
Post by: TimSpangler on November 01, 2006, 12:31:27 PM
That works but not  exactly what I was looking for.

( actually used that first only slightly differant)
Code: [Select]
(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.
Title: Re: Xline help
Post by: Crank on November 02, 2006, 03:15:37 PM
I use this (no error check):
Code: [Select]
(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)
)
Title: Re: Xline help
Post by: TimSpangler on November 03, 2006, 07:41:28 AM
Crank that did the trick.

Thanks man.

(I'll have to add that to my bag'o tricks)