Jump to content

Recommended Posts

Posted

HI,

I have troubles with some drawings.

The drawings are reduced to one layer, but all the "information" is still in the drawing but indicated by different colours.

Is there a possibility to swap all objects with a specific colour to a new Layer (like colour_name)?

Since there are a lot of colours in the dwgs, it is a lot of work selecting all objects with the colour (RGB) and swap them to a new layer manually.

can anybody help me?

regards

Franz

Posted
28 minutes ago, Cad64 said:

Have you tried using Quick Select? See HERE.

Thank You! This is what I meant doing it manually. There are 60-80 different colours in a drawing. doing it step by step is very time consuming.

 

Posted (edited)

Here's a start -

(defun c:col2lay ( / c i l s x )
    (if (setq s (ssget "_X" '((410 . "Model"))))
        (repeat (setq i (sslength s))
            (setq i (1- i)
                  x (entget (ssname s i))
                  l
                (cond
                    (   (setq c (cdr (assoc 420 x))) (LM:true->rgb c))
                    (   (setq c (cdr (assoc 062 x))) (list c))
                    (  '(256)   )
                )
            )
            (entmod (subst (cons 8 (apply 'strcat (mapcar 'strcat '("Layer_""_""_") (mapcar 'itoa l)))) (assoc 8 x) x))
        )
    )
    (princ)
)

;; 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))
)

(princ)

 

Edited by Lee Mac
  • Like 2
Posted
3 hours ago, Lee Mac said:

Here's a start -

 

Elegant solution, Lee!  :thumbsup:

Posted
30 minutes ago, Grrr said:

Elegant solution, Lee!  :thumbsup:

 

Thanks! 🍺

Posted

It took a moment to find the layer make very nice Lee.

Posted
Quote

 

14 hours ago, Lee Mac said:

Here's a start -

...

Wow, Thank you!

This was a big help!

one little thing would be great, if it could be implemented to change also the color of the layer to selected colour....

 

 

 

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...