Ahhh, good call Lee. I hadn't thought of that myself. Thanks.
I was going to finish mentioning in my last post before I was pulled away,
Your variables can be (setq Variable nil) at the end of each condition after the flag is set. From the looks of your code, after the linetype is run, the flag is set to 1 and if the linetype is brought up again, it won't run as the flag is keeping from doing so.
The purpose for setting the variable as a local is so it will not conflict with other variables, whether they be local (from other routines) or global. So as long as you set your variable back to nil when done with it, you should be able to get away with that.
If anyone else is following along this post, perhaps they can correct me if I'm wrong or if I haven't covered local variables very well.
Also Dibbler, in your 'print list of outcomes ...', you may want to print out only those items that were NOT updated. It'll save a lot on the coding & a lot on time reading through it all to see what was done and trying to determine if anything was missed.
I formatted your code a bit just to show you a clean format of sorts (please be aware, this is just MY style, others here have their own styles that help them understand their code better). The main reason for this is mainly to show you some other options you have for coding.
I rewrote the MyMeas variable section just to show you another way of getting the same information without the use of a variable.
Also, I took out the (progn ... in the 'print list of outcomes' section, notice the "\n" at the end of the prompts, it will do the same thing.
Anyway, this is just for example purposes (I do better with examples).
(defun c:impfix2 (/ i MyMeas Lines selLine Entity flagBORDER FlagBORDERX2
)
;----------------------------------------------------------------------------------------------------------------------------
(setq MyMeas (getvar "measurement")) ; set MyMeas to current value of Measurement
(if (= MyMeas 0) ; if value is 0 (is imperial)
(setvar "measurement" 1) ; Set measurement to 1 & report to user
) ; end if
;----------------------------------------------------------------------------------------------------------------------------
; Another way to write the MyMeas check
(if (= (getvar "measurement") 0)
(setvar "measurement" 1)
)
; This way, I didn't have to use a variable (unless you need it again later in the code)
;----------------------------------------------------------------------------------------------------------------------------
(if (setq i -1
Lines (ssget "_X" '((0 . "ARC,LINE,CIRCLE,SOLID,ELLIPSE,LWPOLYLINE")))
) ; ends the setq
(progn
(while (setq selLine (ssname Lines (setq i (1+ i)))) ; get first line entity
(if (setq Entity (cdr (assoc 6 (entget selLine)))) ; open entity, get 2nd element in list (linetype),
(progn ; start mutiple commands to find all linetypes & reload them.
(cond ( (= (strcase Entity) "BORDER") ; start condition for that ltype
(if (/= FlagBORDER 1) ; if the flag for this linetype is not set to 1
(progn ;start mutiple commands to set linetye & change flag
(command ".Linetype" "L" "BORDER" "acadiso.lin" "Y" "") ;reload the linetype
(setq FlagBORDER 1) ;set flag for this linestyle to 1
); end progn
); end if
);end condition
( (= (strcase Entity) "BORDERX2")
(if (/= FlagBORDERX2 1)
(progn
(command ".Linetype" "L" "BORDERX2" "acadiso.lin" "Y" "")
(setq FlagBORDERX2 1)
)
)
)
; ##### [the other 70+ linetypes go in here] ####
); end the condition
); end the progn
); end the if
); end the 'while' loop
); end the progn
); end the if
(command ".regenall")
(command ".textscr")
;----------------------------------------------------------------------------------------------------------------------------
; print list of outcomes
(princ "\n----------------------------------------------\n")
(princ "\nThe following actions have been performed... \n")
(if (= MyMeas 1)
(princ "\nmeasurement is set to metric\n")
)
(if (= FlagBORDER 1)
(princ "\nLinetype - BORDER - has been updated\n")
)
(if (= FlagBORDERX2 1)
(princ "\nLinetype - BORDERx2 - has been updated\n")
)
(princ "\n----------------------------------------------")
(princ)
); end defun lisp
DOHT !! I move to slow.