Add color to Layer

Add color to Layer

C.Utzinger
Collaborator Collaborator
2,311 Views
20 Replies
Message 1 of 21

Add color to Layer

C.Utzinger
Collaborator
Collaborator

 

Hi

 

It's a simple thing. I just want to add a color to the Layer... How????

 

 

 

(defun c:<Test3 ()
  (tolayer (ssget "_:L") "-I-Ansicht")
  (princ)
) ;_ end of defun
(defun tolayer ( ss lay / i e )
  (repeat (setq i (sslength ss))
    (entmod
      (subst
	(cons 8 lay)
        (assoc 8 (entget (setq e (ssname ss (setq i (1- i))))))
        (entget e)
        )
      )
    )
  )

 

 

Thank you in advance...

0 Likes
Accepted solutions (3)
2,312 Views
20 Replies
Replies (20)
Message 21 of 21

Kent1Cooper
Consultant
Consultant

@c.utzinger wrote:

.... 

If the layer exists and it is off....

 

I tried something with this, but got nothing:

 

(<(cdr (assoc 62 (entget (tblobjname "layer" "LayerNameHere"))))0)

....


That looks like it should be a valid test -- how did you apply the result?

 

In any case, it can be done a little more simply.  It's not necessary to dig out the Layer as an object and extract its entity data.  The (tblsearch) function returns less information, but it does include the color number with the same positive/negative indication of whether the Layer's on:

 

(< (cdr (assoc 62 (tblsearch "layer" "LayerNameHere"))) 0)

Kent Cooper, AIA
0 Likes