Jump to content

Making layers with colours and name


anindya

Recommended Posts

Sir i have to create layers by selection of objectes.i have attached 2 sample drawing for observation.i can do it in going layer command and create different layers with diff name and colours and then through properties include them on that but it is time taking....can it possible by lisp easily???????

49000 HELP.dwg

50000 HELP.dwg

Link to comment
Share on other sites

Sir i have to create layers by selection of objectes.i have attached 2 sample drawing for observation.i can do it in going layer command and create different layers with diff name and colours and then through properties include them on that but it is time taking....can it possible by lisp easily???????

 

Why not just make them all once using macro recorder? Then you can just play the macro whenever you need to. No lisp required.

Link to comment
Share on other sites

You can also do a simple script just save/make a new one in notepad with file extension .SCR and SCRIPT to load

 

-layer n lay1 C lay1 1 LT lay1 dashed
n lay2 c lay2 4 LT center
n lay3 c 5 lay3 LT dashed2

Link to comment
Share on other sites

Sir i have to create layers by selection of objectes.i have attached 2 sample drawing for observation.i can do it in going layer command and create different layers with diff name and colours and then through properties include them on that but it is time taking....can it possible by lisp easily???????

 

As a starting point

 

(defun c:demo (/ col ent flag flag1 i lay ss)
 (setq flag1 T)
 (while (and flag1
             (setq ss (ssget ":L"))
        )
   (setq flag T)
   (while flag
     (setq lay (getstring t "\nEnter New Layer Name <exit>: "))
     (cond ((tblsearch "layer" lay)
            (prompt "\nLayer Already Exists!!!")
           )
           ((= lay "")
            (setq flag nil)
            (setq flag1 nil)
           )
           ((not (snvalid lay))
            (prompt "\nInvalid Layer Name!!!")
           )
           ((and (not (tblsearch "layer" lay))
                 (snvalid lay)
                 (setq col (acad_colordlg 7))
            )
            (entmake (list (cons 0 "LAYER")
                           (cons 100 "AcDbSymbolTableRecord")
                           (cons 100 "AcDbLayerTableRecord")
                           (cons 2 lay)
                           '(70 . 0)
                           (cons 62 col)
                           '(6 . "Continuous")
                     )
            )
            (repeat (setq i (sslength ss))
              (setq ent (entget (ssname ss (setq i (1- i)))))
              (entmod (subst (cons 8 lay) (assoc 8 ent) ent))
            )
            (setq flag nil)
           )
           (T
            (setq flag nil)
            (setq flag1 nil)
           )
     );; cond
   );; while
 );; while
 (princ)
)

 

Hope that helps

Henrique

Link to comment
Share on other sites

The proper way to address this problem is to create a master template file with the layers already included. Thus, whenever a new drawing is created using the template the layers are immediately available for use. Work smarter...not harder. Lisp isn't necessarily the answer to every problem.

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