Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp to copy and auto number layout tabs

3 REPLIES 3
Reply
Message 1 of 4
bull504
4267 Views, 3 Replies

Lisp to copy and auto number layout tabs

Hello everybody,

 

I posted this yesterday in another forum and was advised to bring it here.  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

Tags (1)
3 REPLIES 3
Message 2 of 4
doni49
in reply to: bull504

I asked a question in the other thread and the OP replied.  I'm copying my question and his reply here to make this process clearer.

 

My question:

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.

 

His Reply:

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.



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 3 of 4
wanda.keightley
in reply to: bull504

Hi,

I've tried to utilise this lisp, but can't get it to copy more than once at a time. It's not asking me 

 

(setq layout# (getint "\nHow many copies ?<2>: "))

 

I type .layout to run it, choose copy, choose which layout to copy & it will only give me 1 copy.

 

I need 100! 😄 Don't ask, it's what the client wants. 

 

Any sugestions please?

Message 4 of 4
wanda.keightley
in reply to: bull504

Sorry about this duplication. I was getting an error message, but noted a message down the bottom saying my reply had posted.

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

Post to forums  

Autodesk Design & Make Report

”Boost