Jump to content

lisp to change layer properties if layer name contains text


pnoraa

Recommended Posts

I'm trying to find a lisp to change layer linetypes and colours if they contain certain text in their layer name. e.g if I have a layer called "contour 1234" among others, can a lisp change the colour and linetype of layers starting with contour ? and does anyone know where I can find a lisp for this?

Link to comment
Share on other sites

Change the line type and the color in the code to meet your needs .

 

(defun c:Test (/ lt cl l e)
 ;; Tharwat 19.Sep.2013    ;;
 (setq lt "DASHED" ;; LineType     ;;
       cl 3        ;; Color number     ;;
 )
 (if (not (tblsearch "LTYPE" lt))
   (vla-load
     (vla-get-Linetypes
       (vla-get-ActiveDocument
         (vlax-get-acad-object)
       )
     )
     lt
     "acadiso.lin"
   )
 )
 (while (setq l (tblnext "LAYER" (null l)))
   (if (wcmatch (cdr (assoc 2 l)) "contour*")
     (progn
       (setq e (entget (tblobjname "LAYER" (cdr (assoc 2 l))))
             e (subst (cons 62 cl) (assoc 62 e) e)
             e (subst (cons 06
                            (if (and lt (tblobjname "ltype" lt))
                              lt
                              "Continuous"
                            )
                      )
                      (assoc 06 e)
                      e
               )
       )
       (entmod e)
     )
   )
 )
 (princ)
)
(vl-load-com)

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