Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp for copying and numbering layout tabs

4 REPLIES 4
Reply
Message 1 of 5
bull504
1872 Views, 4 Replies

Lisp for copying and numbering layout tabs

Hello everybody,

 

First time posting on here and not an expert at coding. After some time browsing i have not seen this posted yet. I currently have a Lisp that will duplicate a layout tab. Here is the code.

 

 

(defun c:duplayout ( / CTAB LAYOUT# LAYOUTNAME )
     (setvar "cmdecho" 0)
     (setq ctab (getvar "ctab"))
     (setq layoutname (getstring (strcat "\nLayout to duplicate <" ctab ">: ")))
     (if (= layoutname "") (setq layoutname ctab))
     (initget 6)
     (setq layout# (getint "\nHow many copies ?<2>: "))
     (if (null layout#) (setq layout# 2))
     (repeat layout#
          (command ".layout" "copy" layoutname "")
);repeat
(princ)
);defun

 

As you can see it asks which tab to duplicate then how many copies. I would like to keep those features but modify it so it will take an existing layout with a suffix (such as 201E) and then duplicate that tab the entered number of copies then auto number the tabs in sequenstial order (i.e. 202E, 203E, 204E,...)

 

First off, is this possible?

 

If so, what lines do I need to add?

 

Any input is much appreciated, Thanks

4 REPLIES 4
Message 2 of 5
bull504
in reply to: bull504

Or I could use a Lisp that will rename existing tabs along the same premices

Message 3 of 5
doni49
in reply to: bull504

Welcome to the forums!

 

1) There is a board specifically for Autolisp discusssions.  I say this just because there's a greater concentration of people over there who understand it.  You will likely find SOME people here on this board that understand it (myself included) but not as many.

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

 

2) I'll offer a few comments to get you started in the right direction.  Will the formatting always be the same?  i.e. 201E, 202E.  So we take the last character off and have an integer value (201) to which we add 1?  If that's the case, you'll want to look at the substr function.  This will get a specified portion of a given string.  You'll then add 1 to the value and copy the tab.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 4 of 5
bull504
in reply to: doni49

1)Thank you for that input, i will direct this question over on that forum as well.

 

2) No, there will be a few other formats, we will have other suffix's such as 301D, 302D.... as well as a prefix such as FAB201, FAB202...

These will be in different drawings of course. If need be I guess i can write 3 different Lisp's sepecified for the different characters.

Message 5 of 5
doni49
in reply to: bull504

The OP has reposted this question over in the AutoLISP forum.  If you'd like to reply, please do so in the other thread to avoid confusion.

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-copy-and-auto-number-layout-t...



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost