Page Numbering for layouts using Fields and Lisp

Page Numbering for layouts using Fields and Lisp

charlesc32
Contributor Contributor
2,357 Views
12 Replies
Message 1 of 13

Page Numbering for layouts using Fields and Lisp

charlesc32
Contributor
Contributor

I need to setup Page Numbering for my layouts using Field & Lisp or other if applicable. My job requires the engineers & drafters to generate drawings for fabrication and the layout pages are numbered manually. I would like to automate this process and, as I understand it, using Field expressions combined with AutoLisp can accomplish this. I'm not sure how to link the 2 or write the proper code to identify the total number of layouts and number each page accordingly. Any help would be appreciated.

 

Thanks,

Charles C

0 Likes
Accepted solutions (1)
2,358 Views
12 Replies
Replies (12)
Message 2 of 13

daniel_cadext
Advisor
Advisor

I use an attribute with a field $(getvar,"ctab")

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 4 of 13

Sea-Haven
Mentor
Mentor

We like others had custom lisps that included update 2 attributes in our title block in the layouts. Sheet No & Total.

 

Another was read a couple of lines of each layout title block and build an Index table in a layout. This provided like 80% of what we needed. Change title block attributes faster to make a new table and delete old. 

 

Make blank layouts using layout copy, update 1 layout title block, and copy all details to other title blocks. 

0 Likes
Message 5 of 13

charlesc32
Contributor
Contributor

Hello Paullimapa

 

I looked through the threads you suggested and you'll have to pardon my ignorance but I'm not clear as to how to run a Lisp program using Field. I've loaded the Lisp files and I don't see them when I open Field Category: Other, Field names: LispVariable, and I searched the Lisp variable: list and I didn't see any of the lisp programs I wish to run. Do I load the lisp file(s) via an Attribute only or can I use Field? How do I go about executing the recommended files?

 

I've also tried to replicate the title block in the renamepagestrial-tabnumbered and basically use the page counting and numbering ability since this block works great for my needs. When I open Field for the total number of pages, I don't understand the formula setup where 24-1 is listed in the formula. Any light you can shed on this would be greatly appreciated.

 

Thank you for your patience

0 Likes
Message 6 of 13

paullimapa
Mentor
Mentor

To demonstrate I've attached the following:

1. drawing Tabnumber.dwg shared in OP(originally called renamepagestrial.dwg)- download & open in your AutoCAD session

2. lisp code: Tabnumber.lsp - to load, save this to a location like My Documents, then open Windows Explorer to My Documents folder, select Tabnumber.lsp, drag & drop it onto your AutoCAD graphics drawing area

 

Tabnumber.dwg contains 20 layouts each with the same title block containing a number of attributes including SHEET #. To run lisp code at command prompt type: Tabnumber

Then select: 3 OF 24

paullimapa_1-1687403292272.png

At the next prompt:

Enter Number To Subtract from Total Layout Quantity: <0>:

Hit Return to accept 0

An alert box will appear showing you what the lisp function will now do:

paullimapa_2-1687403400385.png

Then it will cycle through each layout locating the matching title block name & the same attributes under SHEET # , input the layout order as the first # before OF and the total # of layouts after OF

The lisp function will conclude with the following alert windows when successfully completed

paullimapa_3-1687403414000.png

Now each layout's SHEET # section will automatically be filled like this:

paullimapa_4-1687403763434.png

If you move layout P02 to before P01 and do a REGEN, the SHEET # section will update automatically

Likewise if you copy layout P02 as P02 (2) and do a REGEN the SHEET # section will again update accordingly.

paullimapa_5-1687403908102.pngpaullimapa_6-1687403936932.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 13

vladimir_michl
Advisor
Advisor
0 Likes
Message 8 of 13

charlesc32
Contributor
Contributor

Hello Paul

Thank you for the files and information. The solution is working as needed. Although, when I reduce the number of tabs to reduce the layout quantity, instead of removing the unwanted tabs/layouts, the program marks them as 0 for the first one and negative for the others (if more than one). Plus this occurs at the beginning of the list of tabs/layouts and not at the end. For example, when executing Tabnumber, I removed 5 Tabs/Layouts and the pgm kept all 20 layouts numbering the first one, reading from left to right, -4 of 15, -3 of 15, -2 of 15, -1 of 15, 0 of 15, 1 of 15,...Can the program actually delete the unwanted Tabs/Layouts?

 

With my job I never know how many total Layouts I'm going to need from project to project. This program doesn't add Tabs/Layouts and I guess I'll have to use Copy to add more than the default quantity.

 

Thank you for all the feedback,

I truly appreciate the assistance,

Charles

0 Likes
Message 9 of 13

paullimapa
Mentor
Mentor
Accepted solution

1. >> Enter Number To Subtract from Total Layout Quantity: <0>:

Let me clarify what this prompt does when a # greater than 0 is entered: 

The layout tab count order is based on the first one listed so layout tab #1 always starts from left to right. This is best used when you have a different set of title blocks placed at the start order of the layouts so the program will ignore the total # of layouts & use the # you entered.

2. The program will change all matching title block attributes as long as they're in the drawing and located in any layout tab. Only matching title block attributes located in the Model tab will be ignored.

2. This program does not remove or add any layout tabs or erase or add objects like the title blocks 

3. You can manually delete as many layouts selected using combination of left mouse click + Ctrl or Shift, right mouse click & select on the cursor menu delete and then the matching title block attributes will automatically update on the remaining layouts

4. You can manually copy as many layouts selected using combination of left mouse click + Ctrl or Shift, right mouse click & select on the cursor menu Move or Copy and then all the matching title block attributes will automatically update on new as well as remaining layouts

Hope this clarifies what the program can do vs does not do. 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 10 of 13

charlesc32
Contributor
Contributor
Thank you for the clarification. The program will be a great help moving forward.
0 Likes
Message 11 of 13

paullimapa
Mentor
Mentor

Glad to have helped….cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 12 of 13

charlesc32
Contributor
Contributor

Hello Paul

 

Happy 4th.

 

Would it be possible to create a second group of layouts within the same drawing with a separate numbering scheme independent of the initial group outlined in this topic?

 

At the office we create drawings and layouts for fabrication and welding. The Weld page numbers have to start from 1 to X. As it stands, we're creating a separate drawing for this purpose but management would like for the entire job to be under one drawing.

 

Let me know.

 

Thanks for the help

0 Likes
Message 13 of 13

Sea-Haven
Mentor
Mentor

You could use the layout number is read from the layout name, we used D01, D02 etc so if you have F01 F02 and W01 W02 they would be different and the total would again be based on the layout name. Look for F or W. Let us know if that sounds feasible and what the layout names would be. It would not do total as a field but rather for me just run a lisp then close or save. 

 

I have also plot layouts by range so you can plot all the fabrication in one go in an easy choose as it uses plot 1-5 then 6-99 the 99 implies last layout.