Author Topic: Lisp to change layer colors....  (Read 4777 times)

0 Members and 1 Guest are viewing this topic.

cyclops

  • Newt
  • Posts: 21
Lisp to change layer colors....
« 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
It's 'O'Neill', with three L's!!!! (Jack O'Neill)

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Lisp to change layer colors....
« Reply #1 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.

cyclops

  • Newt
  • Posts: 21
Re: Lisp to change layer colors....
« Reply #2 on: March 09, 2017, 03:45:48 PM »
Lee,
I will try this out.
Thanks
CyclOps
It's 'O'Neill', with three L's!!!! (Jack O'Neill)