Author Topic: Set color to 56 not color of old layer - disregard this post  (Read 2095 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Set color to 56 not color of old layer - disregard this post
« on: February 21, 2019, 05:05:17 PM »
Disregard that last post.
« Last Edit: February 21, 2019, 05:53:20 PM by jlogan02 »
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Set color to 56 not color of old layer
« Reply #1 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)

jlogan02

  • Bull Frog
  • Posts: 327
Re: Set color to 56 not color of old layer - disregard this post
« Reply #2 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.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

jlogan02

  • Bull Frog
  • Posts: 327
Re: Set color to 56 not color of old layer - disregard this post
« Reply #3 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.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Set color to 56 not color of old layer - disregard this post
« Reply #4 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.

jlogan02

  • Bull Frog
  • Posts: 327
Re: Set color to 56 not color of old layer - disregard this post
« Reply #5 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
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10