• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

rename multiple layouts simultaneously

  • Thread starter Thread starter riccardo.sistema
  • Start date Start date
Good morning,
I wrote this

(defun c:nlay (/ n1 n2 lays)
(vl-load-com)
(seq n1 0)
(1)
(setq lays (vla-get-layouts))
(vlax-for x lays)
(if (not (eq (strcase (vla-get-name x))) "model")
(progn)
(vla-put-name x (strcat "bie-pe-tav-im." (itoa n1)" (itoa n2))
(if (= n2 1000)
(progn)
(setq n1 (1+ n1)
0
)
)
)
)
)
(setq n2 (1+ n2))
)
)


but I miss a zero in the numbering from 1 to 9, I compile bie-pe-tav-im.01 instead of bie-pe-tav-im.001, from the double digit on then it is correct bie-pe-tav-im.010
I don't know how to make him understand this.
 
add to your lisp function
Code:
; ritorna n caratteri a destra della stringa
(defun strright (txt n / l)
(setq l (strlen txt))
(substr txt (1+ (- l n)))
)
replace the line
(vla-put-name x (strcat "bie-pe-tav-im." (itoa n1)" (itoa n2))

with

(vla-put-name x (strcat "bie-pe-tav-im." (strright (strcat "000" (rtos n2 2 0)) 3))

the variable n1 does not need
with this change you can manage names from 001 to 999

(vla-put-name x (strcat "bie-pe-tav-im." (strright (strcat "0000" (rtos n2 2 0)) 4))
with this change you can manage names from 0001 to 9999
 
a dubbio
io l ho scritta cosi ma il primo disegno parte da 000 invece che da 001.
What is it?

(defun c:rinlay (/ n1 n2 lays)
(defun strright (txt n / l)
(setq l (strlen txt))
(substr txt (1+ (- l n)))
)
(vl-load-com)
(setq n2 1)
(setq lays (vla-get-layouts (vla-get-activedocument)))
(vlax-for x lays
(if (not (eq (strcase (vla-get-name x)) "model"))
(progn)
(vla-put-name x (strcat "bie-pe-tav-im." (strright (strcat "000" (rtos n2 2 0))))))
(if (= n2 999)
(progn)
(setq n1 (1+ n1)
n2 0
)
)
)
(setq n2 (1+ n2))
)
)
 
Code:
(vl-load-com)
(defun c:rinlay (/ x n2 lays)
(setq n2 1)
(setq lays (vla-get-layouts (vla-get-activedocument)))
(vlax-for x lays
(if (not (eq (strcase (vla-get-name x)) "model"))
(progn)
(vla-put-name x (strcat "bie-pe-tav-im." (strright (strcat "000" (rtos n2 2 0))))))
(setq n2 (1+ n2))
)
)
)
)
(defun strright (txt n / l)
(setq l (strlen txt))
(substr txt (1+ (- l n)))
)
See if that's the way
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top