TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cyclops on March 04, 2017, 02:37:05 PM

Title: Lisp to change layer colors....
Post by: cyclops on March 04, 2017, 02:37:05 PM
The swamp,
I am looking for a LISP routine that will change a group of layers colors by a value of X.

Let say, the layer group *V-UTIL-* has a color value(s) of X, the LISP command will evaluate the color value each layer in the layer group, then bump the layer color value by a constant value (positive or negative).

For example
BEFORE
Layer                Color
v-util-strm          11
v-util-sswr          13
v-util-watr          15

AFTER
Layer                Color
v-util-strm          13 or 09
v-util-sswr          15 or 11
v-util-watr          17 or 13

Thanks for the help in advance.
CyclOps
Title: Re: Lisp to change layer colors....
Post by: Lee Mac on March 04, 2017, 03:57:14 PM
Try the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:laycolshift ( / int pat )
  2.     (if (and (setq pat (strcase (getstring t "\nSpecify layer name pattern: ")))
  3.              (setq int (getint "\nSpecify colour shift: "))
  4.         )
  5.             (if (wcmatch (strcase (vla-get-name lay)) pat)
  6.                 (vla-put-color lay (max (rem (+ int (vla-get-color lay)) 256) 1))
  7.             )
  8.         )
  9.     )
  10.     (princ)
  11. )

For your example, you would enter v-util-* and plus or minus 2 at each respective prompt.
Title: Re: Lisp to change layer colors....
Post by: cyclops on March 09, 2017, 03:45:48 PM
Lee,
I will try this out.
Thanks
CyclOps