Jump to content

Recommended Posts

Posted

hi sir

please if you can help me

i have sheet with layout name start from

BWSIP-2R-DD-TP-M01 to BWSIP-2R-DD-TP-M10

now i take copy from this sheet but i want to rename layout name frome 01..10

to BWSIP-2R-DD-TP-M02 to BWSIP-2R-DD-TP-M20

Posted

In the time it takes to work out a lisp they could be renamed just click on the last one and use "Rename" option if you have more than 10 and this occurs all the time then please confirm.

Posted

thank sir for you replay

really yes always we have project some time more 70 layout in on sheet

and we copied for other design

Posted

Found a couple of minutes try this it has no error checking about layout names and numbers within.

 

(vl-load-com)
(defun renumlayout ( / doc tabs len tabsnewnum lenstr layname)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq tabs  (vla-get-Layouts doc))
(setq len (vla-get-count tabs))
(alert (rtos len 2 0))
(setq newnum (getint "input last layout number"))
(if (> newnum len)
(vlax-for layname tabs
(setq tabname  (vla-get-name layname))
(if (= "Model" tabname)
(princ)
(progn
(setq lenstr (strlen tabname))
(setq tabname (substr tabname 1 (- lenstr 2)))
(vla-put-name layname (strcat  tabname (rtos newnum 2 0)))
)
)
(setq newnum (- newnum 1))
)
)

(princ)
)
(renumlayout)

Posted

Here's a quick example:

(defun c:foo (/ i l n o)
 ;; Prefix
 (setq pre "BWSIP-2R-DD-TP-M")
 ;; Start number
 (setq n 1)
 ;; Get all paperspace layouts
 (vlax-for x (setq lo (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))))
   (cond ((> (vla-get-taborder x) 0) (setq o (cons x o))))
 )
 ;; Sort left to right
 (setq o (vl-sort o '(lambda (r j) (< (vla-get-taborder r) (vla-get-taborder j)))))
 ;; Apply a temp name to avoid duplicates
 (foreach l o (vla-put-name l (rtos (/ (getvar 'cdate) (vla-get-taborder l)) 2 12)))
 ;; Renumber
 (foreach l o
   (setq i (cond ((< n 10) (strcat "0" (itoa n)))
	  ((itoa n))
    )
   )
   (vla-put-name l (strcat pre i))
   (setq n (1+ n))
 )
 (princ)
)
(vl-load-com)

Posted
< ... >
 ;; Apply a temp name to avoid duplicates
 (foreach l o (vla-put-name l (rtos (/ (getvar 'cdate) (vla-get-taborder l)) 2 12)))
< ... >

 

Interesting - I typically use the Layout Handle ;)

Posted
Interesting - I typically use the Layout Handle ;)

 

That's because you're smarter than me :)

Posted

I am not sure I understand Lee's suggestion, but in theory a layout may have a name that matches the handle of another layout. So using layout handles as temporary names can be risky.

Posted
I am not sure I understand Lee's suggestion, but in theory a layout may have a name that matches the handle of another layout. So using layout handles as temporary names can be risky.

 

That applies to any methodology you choose...

Posted

Requesting for a LSP that can change layout tab from its original tab name into a new name(user defined). Hoping you can help me creating this script data.

 

Would like to create a batch layout rename.

 

TIA :)

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