;;;Set layer color and linetype for selected entity. ;;;If entity colors and linetypes are bylayer the effect is to change the ;;;color and linetype of entities on the selected entity's layer. ;;; ;;;Specifically: This routine allows changing of Xref layer color and linetype ;;; by a simple selection of a visible xref entity. ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: 2-5-96 ;;;> EDITED: 12-06-2005 ;;; (DEFUN c:lapset (/ lnlen xrnm lmsg blees nentl orig_ent) (SETQ old_expert (GETVAR "expert")) (SETVAR "expert" 5) (SETQ lstr "" unmkl (GETVAR "clayer") ) ;_ end of setq (IF clnmstd nil (LOAD "mklayr" "\nFile MKLAYR.LSP not loaded! ") ) (IF ukword nil (LOAD "ukword" "\nFile UKWORD.LSP not loaded! ") ) (SETQ newlacolr (ukword 1 "Unchanged 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255" "New layer color or nchanged " (IF newlacolr newlacolr "Unchanged" ) ;_ end of if ) ;_ end of ukword ) ;_ end of setq (SETQ curltyp_lst (LIST (STRCASE (CDR (ASSOC 2 (TBLNEXT "ltype" T))) T))) (WHILE (SETQ nxtltyp (TBLNEXT "ltype")) (IF (NOT (WCMATCH (CDR (ASSOC 2 nxtltyp)) "*|*")) (SETQ curltyp_lst (APPEND curltyp_lst (LIST (STRCASE (CDR (ASSOC 2 nxtltyp)) T)))) ) ) (foreach n curltyp_lst (setq curltyp_lst (subst (strcat (strcase (substr n 1 1)) (substr n 2)) n curltyp_lst ) ) ) (setq newltyp_lst curltyp_lst) (setq cnt 0) (while (< cnt (length curltyp_lst)) (foreach n (append (reverse (cdr (member (nth cnt curltyp_lst)(reverse curltyp_lst))))(cdr(member (nth cnt curltyp_lst) curltyp_lst))) (setq chrcnt 1) (while (and (wcmatch (substr (nth cnt curltyp_lst) 1 chrcnt) (substr n 1 chrcnt)) (< chrcnt (strlen n)) (< chrcnt (strlen (nth cnt curltyp_lst))) ) (setq chrcnt (1+ chrcnt)) (setq newltyp_lst (subst (strcat (strcase (substr (nth cnt newltyp_lst) 1 chrcnt))(substr (nth cnt newltyp_lst) (1+ chrcnt))) (nth cnt newltyp_lst) newltyp_lst ) ) (setq newltyp_lst (subst (strcat (strcase (substr n 1 chrcnt))(substr n (1+ chrcnt))) (CAR (MEMBER (strcase n t) newltyp_lst)) newltyp_lst ) ) ) ) (setq cnt (1+ cnt)) ) (setq kwdstr "") (foreach n newltyp_lst (if (WCMATCH n "*_*") (COND ((WCMATCH n "*_L") (SETQ newkword (STRCAT (SUBSTR n 1 (-(STRLEN n)2)) "zL")) (SETQ substlmsg "Linetype ending in \"_L\" keyword has substituted \"z\" for \"_\". ") (if kwdstr (setq kwdstr (strcat kwdstr " " newkword)) (setq kwdstr newkword) )) ((WCMATCH n "*_R") (SETQ newkword (STRCAT (SUBSTR n 1 (-(STRLEN n)2)) "zR")) (SETQ substrmsg "Linetype ending in \"_R\" keyword has substituted \"z\" for \"_\". ") (if kwdstr (setq kwdstr (strcat kwdstr " " newkword)) (setq kwdstr newkword) )) (T NIL) ) (if kwdstr (setq kwdstr (strcat kwdstr " " n)) (setq kwdstr n) ) ) ) (PRINC "\nLinetypes available: ") (PRINC newltyp_lst) (IF substlmsg (PROGN (PRINC "\n") (PRINC substlmsg) (SETQ substlmsg NIL) (PRINC) ) ) (IF substrmsg (PROGN (PRINC "\n") (PRINC substrmsg) (SETQ substrmsg NIL) (PRINC) ) ) (PRINC) (WHILE (AND kwdstr (WCMATCH kwdstr " *")) (SETQ kwdstr (SUBSTR kwdstr 2)) ) (SETQ newlaltyp (ukword 1 (IF kwdstr (STRCAT "Unchanged " kwdstr) "Unchanged") (STRCAT "New layer linetype or nchanged "(if (and kwdstr (eq (type kwdstr) 'STR))(STRCAT "[" kwdstr "]") "")) (IF newlaltyp newlaltyp "Unchanged" ) ;_ end of if ) ;_ end of ukword ) ;_ end of setq ;;; (PRINC "\n1=") ;;; (PRINC (strlen newlaltyp)) ;;; (PRINC newlaltyp) ;;; (PRINC "\n2=") ;;; (PRINC (strlen newlacolr)) ;;; (PRINC newlacolr) (PRINC) (WHILE (AND (NOT (AND (EQUAL (STRCASE newlaltyp) "UNCHANGED") (EQUAL (STRCASE newlacolr) "UNCHANGED") ) ) ;_ end of not (SETQ nent (NENTSEL)) ) (SETQ blees (LENGTH (CAR (REVERSE nent)))) (IF nent (PROGN (IF (AND (EQ (CDR (ASSOC 8 (ENTGET (CAR nent)))) "0") (EQ (LENGTH nent) 4)) (SETQ sellaname (CDR (ASSOC 8 (ENTGET (CAAR (REVERSE nent)))))) (SETQ sellaname (CDR (ASSOC 8 (ENTGET (CAR nent))))) ) ;_ end of if (SETQ ladef (TBLSEARCH "layer" sellaname)) (IF (EQUAL (STRCASE newlacolr) "UNCHANGED") (SETQ newlacolr "Unchanged") ) ;_ end of if (IF (EQUAL (STRCASE newlaltyp) "UNCHANGED") (SETQ newlaltyp "Unchanged") ) ;_ end of if (IF (WCMATCH newlaltyp "*z[L R]") (SETQ newlaltyp (STRCAT (SUBSTR newlaltyp 1 (-(STRLEN newlaltyp)2)) "_" (SUBSTR newlaltyp (STRLEN newlaltyp)))) ) (COND ((EQUAL newlaltyp "Unchanged") (COMMAND ".layer" "c" newlacolr sellaname "")) ((EQUAL newlacolr "Unchanged") (COMMAND ".layer" "lt" newlaltyp sellaname "")) (T (COMMAND ".layer" "c" newlacolr sellaname "lt" newlaltyp sellaname "")) ) ;_ end of COND (ENTUPD (CAR nent)) ) ;_ end of progn (PRINC "\nNothing selected. ") ) ;if nent ) ;_ end of while (IF (AND (EQUAL newlacolr "Unchanged") (EQUAL newlaltyp "Unchanged")) (PROGN (PRINC "\nYou said both color and linetype will remain unchanged. Nothing to change. ") (PRINC) ) ) (SETVAR "expert" old_expert) (IF lmsg (PRINC lmsg) ) (PRINC) ) ;|«Visual LISP© Format Options» (120 2 15 2 T "end of " 100 9 2 0 nil nil nil T T) ;*** DO NOT add text below the comment! ***|;