layer rename

layer rename

Anonymous
Not applicable
1,275 Views
3 Replies
Message 1 of 4

layer rename

Anonymous
Not applicable

hello. this is layer rename lsp that is only a partial change.

I want to remove that input texts.

for example. if there are layer names.   aaabx1. aaavv2. aaaxy3. aaazz4... etc.

input "aaa"

bx1

vv2

xy3

zz4... etc

always thank you all for help.

(defun c:lann (/ old new doc)
 (vl-load-com)
 (and
 (setq old (getstring T "\nold\w string: "))
 (or
 (snvalid old 1)
 (prompt " Invalid string.")
 )
 (setq new (getstring T "\nnew string: "))
 (or
 (snvalid new 1)
 (prompt " Invalid string.")
 )
 (or
 (/= new old)
 (prompt " Same string.")
 )
 (vlax-for layer
 (vla-get-layers
 (vla-get-activedocument
 (vlax-get-acad-object)
 )
 )
 (vla-put-name
 layer
 (vl-string-subst
 new
 old
 (vla-get-name layer)
 )
 )
 )
 )
 (princ)
 )

0 Likes
Accepted solutions (1)
1,276 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant

Use the Rename command.

Old name *

New name: aaa*

0 Likes
Message 3 of 4

dbhunia
Advisor
Advisor
Accepted solution

Try this.....

 

(defun c:lann (/ old new doc)
(vl-load-com)
(and (setq old (getstring T "\nold string: "))
      (or (snvalid old 1) (prompt "\nInvalid string."))
)
(vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
        (vla-put-name layer (vl-string-subst "" old (vla-get-name layer)))
)
(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 4 of 4

Anonymous
Not applicable

thank you...

0 Likes