This would give you the number of layouts that you have in a drawing .
But what do you mean by update the sheet no field in the title block ?Code:(length (layoutlist))
Registered forum members do not see this ad.
Hi.,
I need a lisp routine to count the number of layouts (layouts name will be not be specific & is random ) in a drawing from starting to end, and update the sheet no field in the title block ex: '1 of 5', '2 of 5', etc...
Can any one guide how to do it??
regards
r.sekar
This would give you the number of layouts that you have in a drawing .
But what do you mean by update the sheet no field in the title block ?Code:(length (layoutlist))
In Pseudo Code it might be something along the lines of:
- Initialise counter variable to 1 and another variable to store number of layouts (as a string)
Code:(setq sheet 1) (setq total (itoa (length (layoutlist))))
- Iterate through list of layouts.
Code:(foreach layout (layoutlist) ... )
- For each layout name, acquire a SelectionSet of attributed blocks of a specific name inserted in that layout
Code:(ssget "_X" (list (cons 0 "INSERT") (cons 66 1) (cons 2 "YourBlockName") (cons 410 layout)))
- Iterate through the attributes of each block in the SelectionSet (entnext)
- Update the attribute with tag pertaining to the sheet number using a concatenation of the counter variable and variable containing total number of layouts
Code:(strcat (itoa sheet) " of " total)
- Increment the counter
Code:(setq sheet (1+ sheet))
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper



r.sekar,
There is a much easier way to do it with fields. The only thing is that you would need to number the layouts as 1,2,3,4,5.....etc. And use another field for the total number pages. I have it setup this way and it works very well. A simple regenall updates the fields.
I attach a layout with the fields.
Note also a field used for the scale. If you change the viewport scale and regenall the scale updates. The sheet size is updated based on the Page Setup used to plot.
new block.dwg
It's not working for me:
capture_07092011_080746.jpg
I note that your total is coming from the USERS5 system variable. You probably have some lisp setting it for you. This is why I don't like doing it this way - if the field is used on a ACad which doesn't have that Lisp loaded, you get what's displayed in my screen capture.

Not working here also. Regen has no effect.
I know by experience that if u use a field in a attribute, you can't get the code back that was inserted.
Can you please give the code you inserted, and in what kind of field, sorry stil very new to this.
Mvg John
not native english
I haven't looked at the drawing, but I would guess that woodman has used a field referencing a LISP Variable (or User System Variable which is updated by a LISP code) to display the total number of layouts. Since a LISP variable will only hold its value during the current drawing session (while the document namespace exists) it would need to be setq'd every time the drawing is opened for the field to display the correct value.
I can't immediately see a way to display the total number of layouts using a field without referencing a LISP Variable or User System Variable, so would recommend the OP follows the directions I describe in post #3.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
I would recommend you learn about "Sheet Sets": http://heidihewett.blogs.com/my_webl...ets_Happen.pdf
"Work Smart, Not Hard"
Click to View My Portfolio ( Updated 05/21/2013 ) ---> http://www.rdeweese.com/
I'm unsure what you're referring to.
Firstly woodman's drawing has the fields inside a normal MText inside a block or simply as MText on the layout page (not attributes). Secondly I've never been unable to get at the field-code because it was in an attribute, are you perhaps referring to formula fields? Those have a tendency to become "uneditable" if they are the only thing in text/attrib/table-cell.
Woodman's drawing (as I've stated before) loads the "Sheet # of ##" by having 2 fields:
(1) a field pointing to the CTab system variable to get the current tab's name. Field code is "%<\AcVar ctab>%"
(2) a field pointing to a Diesel expression simply retrieving the USERS5 system variable. Field code is "%<\AcDiesel $(getvar,users5)>%".
If you're referring to the Date, Issue Date, Scale and Sheet Size, they are respectively: "%<\AcVar CreateDate \f "d MMMM yyyy">%"; "%<\AcVar Date \f "dd.MM.yyyy">%"; "%<\AcExpr ((1/%<\AcVar PlotScale \f "%lu2%qf2816">%)*1000/%<\AcObjProp Object(%<\_ObjId 2124506408>%).CustomScale \f "%lu2%qf2816">%) \f "%lu2%pr0">%" and "%<\AcVar.17.0 Lisp.ccc_sheet>%".
I've got a problem with the last one which gets its value from a lisp variable (which on my PC is nil), same as the USERS5 which is "" (blank text). It might have worked if woodman also attached the LSP which sets/creates these 2.
Registered forum members do not see this ad.
could it be that Woodman's is a function of Civil? I know electrical has some automatic page numbering and other reference information built in.
"That's it. It's one thing for a ghost to terrorize my children, but quite another for him to play my Theremin." Homer Simpson
Dave
Bookmarks