Jump to content

TABLESTYLE Text for Title & Headers


Bill Tillman

Recommended Posts

I need a way to accurately and quickly count objects in an AutoCAD file and once again, our main man Lee-Mac has an excellent example called TCount which fits the bill nicely. Here are some additional features I could use some advice on for expanding it.

  1. The detail call outs I'm counting are a block which is a circle with a horizontal line through its center. The block contains two attributes, the top being the Mark # of the part, and this one is the target I'm after, and the bottom attribute being the sheet number. The sheet number is not of any interest at this point so I would like to know if there is a way I could omit these instances showing up in the data table.
  2. The TABLESTYLE command is useful for getting the font set to the size and colors I want, but the text in the Title on the Header fields is rather generic. I'd like to know if there is a way to change the text, beside editing it manually after the table is created. Doing it with the LISP code would be fine or to be able to set the desired text in the TABLESTYLE window would work as well.

Link to comment
Share on other sites

Fast-forward 1/2 hour and I did find the variables to change the text in the data table. That's cool. Now to figure out how to by pass the 2nd attribute of each block...

 

Fast-forward another 45 minutes, got the pizza delivered and now I got a 3rd column.

Edited by Bill Tillman
Link to comment
Share on other sites

Have a look at this

 

; dwg index to a table
; by Alan H NOV 2013
(defun AH:dwgindex (/ doc objtable ss1 lay ans ans2 plotabs ss1 tag2 tag3 list1 list2 curlayout colwidth numcolumns numrows INC rowheight )

(vl-load-com)
(setq curlayout (getvar "ctab"))
(if (= curlayout "Model")
(progn
(Alert "You need to be in a layout for this option")
(exit)
) ; end progn
) ; end if model
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq curspace (vla-get-paperspace doc))
(setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table:  "))) 

; read values from title blocks

(setq bname "DA1DRTXT")

(setq tag2 "DRG_NO") ;attribute tag name
(setq tag3 "WORKS_DESCRIPTION") ;attribute tag name

(setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname))))

(if (= ss1 nil) ; for tomkinson jobs
(progn 
(setq bname "COGG_TITLE")
(setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname))))
)
)

(setq INC (sslength ss1))  
(repeat INC
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (SETQ INC (- INC 1)) )) 'getattributes) 
       (if (= tag2 (strcase (vla-get-tagstring att)))
           (progn
           (setq ans (vla-get-textstring att))
           (if (/= ans NIL)
           (setq list1 (cons ans list1))
           ) ; if 
           ); end progn
         ) ; end if
       (if (= tag3 (strcase (vla-get-tagstring att)))
         (progn
         (setq ans2 (vla-get-textstring att))
         (if (/= ans2 NIL)
             (setq list2 (cons ans2 list2)) 
          ) ; end if
          ) ; end progn
 ) ; end if tag3 
   
) ; end foreach

) ; end repeat
(setvar 'ctab curlayout)
(command "Zoom" "E")
(command "regen")


(reverse list1)
;(reverse list2)

; now do table 
(setq numrows (+ 2 (sslength ss1)))
(setq numcolumns 2)
(setq rowheight 0.2)
(setq colwidth 150)
(setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "DRAWING REGISTER")
(vla-settext objtable 1 0 "DRAWING NUMBER") 
(vla-settext objtable 1 1 "DRAWING TITLE") 

(SETQ X 0)
(SETQ Y 2)

(REPEAT (sslength ss1)
 (vla-settext objtable Y 0 (NTH X LIST1))
 (vla-settext objtable Y 1 (NTH X LIST2))
 (vla-setrowheight objtable y 7)

 (SETQ X (+ X 1))
 (SETQ Y (+ Y 1))
)

(vla-setcolumnwidth objtable 0 55)
(vla-setcolumnwidth objtable 1 170)

(command "_zoom" "e")

); end AH defun

(AH:dwgindex)

(princ)

Link to comment
Share on other sites

Hey BIGAL, thanks for the code example. I'm looking it over now. But when I tried it out it fails at this line:

(setq INC (sslength ss1))

JunkCapture.jpg

Edited by Bill Tillman
Link to comment
Share on other sites

Did you change the block name (setq bname "DA1DRTXT") and tag names its all hard coded to suit my needs. Its more an example that you will need to pull apart and change to suit your situation.

Link to comment
Share on other sites

Hey BIGAL, yes I found that was the trouble with my testing of the code. I changed the value of the variable bname to be the name of the block I'm testing and it worked, but not with the results I was looking for. I'm examining Lee-Mac's TCOUNT code because it's more of what I think is needed which is a simple text search. The trouble I'm having with it is that the code which counts the text also counts the text I don't want to include. For example, I'm using a block which has two attributes attached to it and I'm only after one of them for the data table.

 

I'm also looking at the DATAEXTRATION command as several articles I've read promote this as a preferred method for accumulating counts. As always with AutoCAD there is more than one way to accomplish a given task.

Link to comment
Share on other sites

The example I posted the block has around 12 attributes as its a title block. I search the tag names.

(setq tag2 "DRG_NO") ;attribute tag name
(setq tag3 "WORKS_DESCRIPTION") ;attribute tag name
..............
(if (= tag2 (strcase (vla-get-tagstring att)))
............

Link to comment
Share on other sites

Bill post a sample dwg, can use nentsel to pick an attribute then look in blocks rather than hard code.

 

(entget (car (nentsel)))

((-1 . <Entity name: 7ffffb7e210>) 
(0 . "ATTRIB") picked an attribute
(1 . "PRELIMINARY DRAWING") text value of attribute
(2 . "DRAWING_STATUS") tag name

Link to comment
Share on other sites

BIGAL,

 

Here is one of the blocks I'm trying to work with. What I would like to do is to be able to select one or many of them and have a data table built like the one in Lee-Mac's Text Count program. It works but it also counts the "FE1.1" fields which is not what I'm after.

Drawing1.dwg

Link to comment
Share on other sites

It may be a wet weekend so should have some time watch this space.

 

Ok I think and there should be something out there already like Lee's tcount, select all your blocks, make a list with all attributes and sort the list.

 

((SLD-01)(SLD-01)(sld-02)(sld-02)(sld-02)) so there are 2 SLD-01 and 3 sld-02 and so on

 

Then just populate the table by counting the list reset every time the name changes.

 

I am not sure why your door block would not be done as a multiple attribute in the table ie three columns.

 

((door1 handle1)(door1 handle1) (door1 handle1)(door1 handle2)) so 3 door1's with handle 1, 1x door1 with handle2

 

Is this what your after ? You can have more than 2 attributes, door1 handle1 gold, door1 handle1 brass. Just need to know write a better version 1st go.

 

It could be a bit of a universal routine rather than hard coded max No attributes ?

 

dataextraction comes to mind.

ScreenShot118.jpg

Edited by BIGAL
Link to comment
Share on other sites

Thanks again BIGAL. I'm using the latest 2019 version of AutoCAD so we're going through install issues for the moment. But I'll get a chance to look at this more in depth later tonight.

Link to comment
Share on other sites

Late to the party here, but barring a lisp that does all you want, a Data Extraction Table can be pretty seriously dialed and tweaked, if you access the right click shortcut menus when setting up your Table Style, which you then SAVE of course. You could set that as your current TableStyle in your drawing or a template, and run it quite quickly. Not as quickly as a lisp, but still pretty impressive once set up. :beer:

Edited by Dadgad
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...