Hi,
I would like to have a page number based on the layout tab order. I am currently using the CTAB field for labeling my page titles, but i would also like something to help number my sheets "page X of XX" is there a way of doing this with a lisp file?
I would like it so if I changed the order of my tabs the numbers would automatically update.
Thanks
Solved! Go to Solution.
Solved by Ranjit_Singh2. Go to Solution.
First part do this:
http://forums.augi.com/showthread.php?141491-Auto-Numbering-Layout-Tabs
Your 2nd question,
Ask the Customization Group
I don't think there are fields to check the order of the layout tab. But I am not sure. I would certainly like to know if there is such a field. Using LISP though, once you get the layouts collection object the taborder property tells you the order of the tab. You would need some kind of reactor to check when the tabs were moved and call a lisp to update the relevant entities to reflect taboder property.
Are the text/mtext entities to be updated in a title block of some sort? Post a sample dwg.
See attached sample. Just using a simple title block that was given to me.
I don't know what you mean by "once you get the layouts collection object the taborder property tells you the order of the tab"
Thanks
Try the below routine.
(defun c:somefunc (/ adoc layouts layoutname ss1 ent entdata) (setq layouts (vla-get-layouts (setq adoc (vla-get-activedocument (vlax-get-acad-object))))) (if (setq ss1 (ssget "_x" '((0 . "INSERT") (2 . "_11x17")))) (mapcar '(lambda (x) (setq ent (cadr x) entdata (entget ent)) (while (/= (cdr (assoc 0 entdata)) "SEQEND") (cond ((= "SHT#" (cdr (assoc 2 entdata))) (vlax-for y layouts (cond ((= (vla-get-name (vla-objectidtoobject adoc (vla-get-ownerID (vlax-ename->vla-object (cdr (assoc 330 entdata)))))) (vla-get-name (vla-get-block y))) (entmod (subst (cons 1 (itoa (vla-get-taborder y))) (assoc 1 entdata) entdata))) (T ()))) )) (setq entdata (entget (setq ent (entnext ent)))))) (ssnamex ss1)) "No titleblocks found!") (princ))
I've seen you get it but, which attribute do you use put the number in your pages before using lisp?
I don't know if you understand me. I am sorry about my poor english.
Thank you so much in advance!
I looking forward you reply!
@Anonymous wrote:
You are amazing. Thank you!
@Anonymous wrote:
You are amazing. Thank you!
@Ranjit_Singh2 wrote:Try the below routine.
(defun c:somefunc (/ adoc layouts layoutname ss1 ent entdata) (setq layouts (vla-get-layouts (setq adoc (vla-get-activedocument (vlax-get-acad-object))))) (if (setq ss1 (ssget "_x" '((0 . "INSERT") (2 . "_11x17")))) (mapcar '(lambda (x) (setq ent (cadr x) entdata (entget ent)) (while (/= (cdr (assoc 0 entdata)) "SEQEND") (cond ((= "SHT#" (cdr (assoc 2 entdata))) (vlax-for y layouts (cond ((= (vla-get-name (vla-objectidtoobject adoc (vla-get-ownerID (vlax-ename->vla-object (cdr (assoc 330 entdata)))))) (vla-get-name (vla-get-block y))) (entmod (subst (cons 1 (itoa (vla-get-taborder y))) (assoc 1 entdata) entdata))) (T ()))) )) (setq entdata (entget (setq ent (entnext ent)))))) (ssnamex ss1)) "No titleblocks found!") (princ))
Hello Ranjit,
I've been looking for this for some weeks. I've tried your lisp but doesn't work at all. Which attribute do you use to number the pages? Because I understand you write page number 1/5, 2/5, ...5/5 and after all, you use autocad lisp, are you?
Thank you so much in advance.
I'm looking forward to hearing from you.
Regards,
Ana
The code specifies the block name ("_11x17") and the attribute name ("SHT#") of the sample title block provided. Change these to your block name and attribute name and the code will work.
See also the PageOf utility (reactor):
https://www.cadforum.cz/cadforum_en/total-number-of-layouts-as-a-field-tip11171
Vladimir Michl, www.cadstudio.cz
Hi wfraser3;
I changed the name of the title block but left the attribute tag the same because I used "SHT#" in the name, but the numbers don't change. I'm using AutoCAD 2023 but I don't know if that has something to do with it.
May you help me with this problem?
Thanks!
Could you add to this source code to make it display total pages in set. For instance if a file has 10 pages make it to where it would say 1 of 10, 2 of 10..... 10/10?
I make a custom property shown in the picture (drawing utilities -> drawing properties -> custom -> add) and then 'insert field' of the custom property in text (in the mtext, right click and find insert field, find the name of the custom property and click insert). You'll have to manually update it from the drawing utilities, but it'll update it for all of the pages if it's in your title block.
I am using the PageOf tool (see Message #12) to update the fields and total number of pages. Quite handy.
Can't find what you're looking for? Ask the community or share your knowledge.