Jump to content

Change hatch layer according to color


muntafuner

Recommended Posts

Hello from Austria,

 

i have a problem and couldn´t find any answers to this particular problem:

 

I would like to change the layers of multiple hatches in the drawing according to the specific colors.

 

For example:

All hatches ar located on the Layer "Poly_Muster", now i would like to select all hatches with the color 153,76,0 and then they should be changed to the layer "Poly_Mauerwerk", all hatches with the color 128,210,4 to "Poly_Stahlbeton" and so on..

 

is there a solution i can do this with a script or a lisp?

 

Thank you in advance!

 

Kind regards,

Simon

Link to comment
Share on other sites

Credit 1s t to lee-mac

;; True -> RGB  -  Lee Mac
;; Args: c - [int] True Colour

(defun LM:True->RGB ( c )
    (mapcar '(lambda ( x ) (lsh (lsh (fix c) x) -24)) '(8 16 24))
)

If you look at this (setq Col (cdr (assoc 420 (entget (car (entsel)))))) pick the hatch returns the color number eg 3899588

 

then (LM:True->RGB col) will convert to a list of RGB 

 

Command: (LM:TRUE->RGB col)
(59 128 196)
 

Sou can do a Cond or if then = list variable

Link to comment
Share on other sites

Thank you for your response!

 

You find a sample-file in the attachment.

 

As you can see, the hatch with the color "128,210,4" lays on the Layer "Poly_Muster" but it should be on the Layer "Poly_Stahlbeton"; the hatch with the color "153,76,0" lays also on the layer "Poly_Muster" but it should be on the layer "Poly_Mauerwerk"... for example.

 

Thank you in advance for your help an response!

 

Kind regards,

Simon

Test01.dwg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...