Jump to content

All enteties layer 0 To layer per color


Lippens Infra

Recommended Posts

Hello,

 

I have a lot of drawings comming from an export f.e. Tekla stuctures. 

Those drawings have no layer structure, only thing to categorize entities are the colors.

Is it possible to create layers per color and get the entities in that layer?

 

Thanks in advance

1A - Fundering.dwg

Link to comment
Share on other sites

Give this a shot and let me know. :) 

(defun c:M2LC (/ int sel get clr lay)
  ;; Tharwat - 21.10.2020	;;
  ;; Move 2 Layer Color.	;;
  (and (setq int -1
             sel (ssget "_:L" '((0 . "~VIEWPORT")))
       )
       (while (setq int (1+ int)
                    ent (ssname sel int)
              )
         (setq get (entget ent)
               clr (cdr (assoc 62 get))
               lay (itoa clr)
         )
         (and clr
              (or (tblsearch "LAYER" lay)
                  (entmake (list '(0 . "LAYER")
                                 '(100 . "AcDbSymbolTableRecord")
                                 '(100 . "AcDbLayerTableRecord")
                                 (cons 2 lay)
                                 (cons 62 clr)
                                 '(70 . 0)
                           )
                  )
              )
         )
         (entmod (append get (list (cons 8 lay) '(62 . 256))))
       )
  )
  (princ)
)

 

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