I have searched and searched for a topic on Customizing Fields. I want to make a custom field that is Sheet 1 of 31 and it populates with the sheet it is and how many sheets total for that set. Can anybody point me in the right direction?
|
I have searched and searched for a topic on Customizing Fields. I want to make a custom field that is Sheet 1 of 31 and it populates with the sheet it is and how many sheets total for that set. Can anybody point me in the right direction?
The easiest way of doing this is with using the sheet set manager. You would make 2 attributes; one for the page number and the other for the set number. "Sheet" & "of" would be just plan text. The attribute for page number will have a field linked to the page number property the the ssm gives. The set number will be a custom field that you would add to the ssm properties.
Check out these threads for working with the sheet set manager.
How do I get fields working with SSM?
Setting up a Sheet Set
Last edited by Glenn Pope; 2005-07-13 at 01:24 PM.
I have tackled this without sheet sets.
I figured that every sheet (layout) has a separate title block and that the number of title blocks = the number of sheets. (If this is not the case for you then this solution will not work).
I then used some lisp code that was suggested on the Autodesk discussion site
http://discussion.autodesk.com/forum...sageID=5902018
-----------------------------------------------------------------------------------------------------------------------
(defun C:THINGCOUNT ()
(setvar "cmdecho" 0)
(setq sa (ssget "x" (list (cons 0 "INSERT")(cons 2 "THING"))))
(setq thingcount (sslength sa))
(princ)
)
---------------------------------------------------------------------------------------------------------------------
###NOTE : REPLACE THE WORD "THING" WITH THE NAME OF YOUR TITLE BLOCK
---------------------------------------------------------------------------------------------------------------------
I added this code to the end of a LISP that I use regularly for other drawing parameters to be set up for plotting, but you could just run it on the default start-up lisp that runs when AutoCad opens. The advantage that I gained by adding it to a lisp that I had assigned to a button was that, using the CUI, I called up the function and added a regen as well (this will ensure that the field value updates whenever I push the button).
Finally just follow the instruction as explained on the link;
---------------------------------------------------------------------------------------------------------------------
now use the FIELD command (or right click over TEXT/MTEXT to insert FIELD behavior to it), use Category 'Other', Fieldname LispVariable and select thingcount (the routine var). the field will pull that count value.
--------------------------------------------------------------------------------------------------------------------
It's not perfect for everyone's scenarios, but it does work.
Congrats on your 1st post ... and that being an answer instead of a question ... nice one. Your idea is good, I like the ease of use ... however ....
The problem here is that the LSP file needs to be loaded, otherwise there is no thingcountlisp variable to link to. So if someone else opens the DWG the field will display #####.
If you don't want to use Sheet Sets, place that sheet count into your Drawing Properties. You can create a custom property ... call it SheetCount ... or whatever takes your fancy. Then change you code to look something like this (changes marked in red):Now there should be a SheetCount property under the Document category for fields. The nice thing here is you can open the DWG without needing to load & run your code every time since it's loading the sheet count from something that's saved inside the DWG itself ... not simply a volatile global variable.Code:(defun C:THINGCOUNT (/ sa thingcount doc si) (setvar "cmdecho" 0) (setq sa (ssget "x" (list (cons 0 "INSERT") (cons 2 "THING")))) (setq thingcount (sslength sa)) (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) ;Get vla-object of current doc (setq si (vla-get-SummaryInfo doc)) ;Get vla-object of summary info of doc (if (vla-GetCustomByKey si "SheetCount") (vla-SetCustomByKey si "SheetCount" (itoa thingcount)) (vla-AddCustomInfo si "SheetCount" (itoa thingcount)) ) (princ) )
I added 2 attributes in my title block (ex: page XX of YY)
The XX variable is a field that AutoCAD provides (SheetNumber) and I created a sheet set custom field called total pages so I manually count the sheets and populate the total sheets field in the top level sheet set.
Here is a link to a thread where a solution was derived to a single file with multiple layout tabs each containing a title block.
http://forums.augi.com/showthread.php?t=95873
irneb:
I am a little confused as to where the code is placed? I made a new Document Field called Total Sheets with a default value of #### but how do I associate the code you modified with the Total Sheets field?
Thank you
eptownie1988
The code can be in any .lsp file. It needs to be loaded in order for it to execute.
IOW - the lisp code populates the drawing property, which in turn is read by the field.
So the code can live anywhere, just make sure the function is loaded into memory before trying to call the "THINGCOUNT" function.
R.K. McSwain | CAD Panacea |
Lee Mac has lisp for this as well: http://www.lee-mac.com/layoutfield.html