TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on February 21, 2019, 05:05:17 PM

Title: Set color to 56 not color of old layer - disregard this post
Post by: jlogan02 on February 21, 2019, 05:05:17 PM
Disregard that last post.
Title: Re: Set color to 56 not color of old layer
Post by: Lee Mac on February 21, 2019, 05:47:03 PM
Hard to advise without seeing the rest of the code, but try:

Code - Auto/Visual Lisp: [Select]
  1.     (progn
  2.         (setq oLayers   (vla-get-layers acDoc)
  3.               oIsoLayer (vla-add  oLayers isoLayerName)
  4.               oLayer    (vla-item oLayers layerName)
  5.         )
  6.         (vla-put-color oIsoLayer 56)
Title: Re: Set color to 56 not color of old layer - disregard this post
Post by: jlogan02 on February 21, 2019, 06:01:08 PM
I decided to tackle the code you helped me with last week.
I've got it to do most everything except again the color.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:demo ( / e i l n s x )
  2.    (if (setq s (ssget "_x" '((8 . "*?`-N") (62 . 1))))
  3.        (repeat (setq i (sslength s))
  4.            (setq x (entget (ssname s (setq i (1- i))))
  5.                  l (assoc 8 x)
  6.                  n (strcat (cdr l) "-56")
  7.            )
  8.            (if (not (tblsearch "layer" n))
  9.                (progn
  10.                    (setq e (entget (tblobjname "layer" (cdr l))))
  11.                    (entmake (subst (cons 2 n) (assoc 2 e) (subst '(62 . 56) (assoc 62 e) e)))
  12.                )
  13.            )
  14.            (entmod (subst (cons 8 n) l x))
  15.        )
  16.    )
  17.    (princ)
  18. )

It will create the copy of the layer and add the suffix "-56" and set the color of the layer to 56. Same thing, I can't get it to set the objects color to 56. Which seems weird to me. If it's moving the objects to the new layer and the new layers color is set to 56, shouldn't the objects color be 56? It will work with a block, but not lines, text and other entities.
Title: Re: Set color to 56 not color of old layer - disregard this post
Post by: jlogan02 on February 21, 2019, 06:17:49 PM
Looking at the color property of the block says it's color is red, but on the screen it's 56, while the color assigned in the layer dialog is 56 for all selected entities.
Title: Re: Set color to 56 not color of old layer - disregard this post
Post by: Lee Mac on February 21, 2019, 06:22:37 PM
If it's moving the objects to the new layer and the new layers color is set to 56, shouldn't the objects color be 56? It will work with a block, but not lines, text and other entities.

Only if the object colour is set to ByLayer.
Title: Re: Set color to 56 not color of old layer - disregard this post
Post by: jlogan02 on February 21, 2019, 07:07:11 PM
I just changed...

Code - Auto/Visual Lisp: [Select]
  1.  (if (setq s (ssget "_x" '((8 . "*?`-N") (62 . 1))))

to

Code - Auto/Visual Lisp: [Select]
  1.  (if (setq s (ssget "_x" '((8 . "*?`-N") (62 . 256))))

and all is fine. I swear I already tried that. Thanks for the nudge. Again. Lee