Jump to content

[Need help] Lisp to add prefix for all freeze layer's name


Nguyen Thong Nhat

Recommended Posts

Hi everyone, I have received a drawing with many layer (see attached image). I want to laytrans some layer (freeze) to a new layer but they have same prefix with other layer. So is there any lisp can find and add prefix all freeze layer in a drawing? then i can use laytrans easier. Thank you very much

image.thumb.png.692d6c335d1ab7e4669bd4994baf15cd.png

Link to comment
Share on other sites

Try this and let me know how it works for you if possible?

NOTE: You can change the word PREFIX- as noted below in the routine that suits your needs, besides that, the layer name 0 & DefPoints along with the External References layer names are excluded as well.

 

(defun c:PrefLayer ( / lay lyn new lst)
  (while (setq lay (tblnext "LAYER" (null lay)))
    (or (wcmatch (setq lyn (cdr (assoc 2 lay))) "0,DefPoints,*|*")
        (and (= 1 (logand 1 (cdr (assoc 70 lay))))
             (or (tblsearch "LAYER" (setq new (strcat "PREFIX-" lyn))) ;; change the prefix word that suits yours
                 (entmod (subst (cons 2 new) (assoc 2 (setq lst (entget (tblobjname "LAYER" lyn)))) lst))
                 )
             )
        )
    )
  (princ)
  )

 

Edited by Tharwat
Note added
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...