I am using Lees Count Program and his Burst Program.
I first have lees burst program explode all dynamic blocks.
Then have the user select all the blocks the want to count.
Place the Count Table where the user wants it,
Last Undo everything to keep the dynamic blocks in tact.
But with this, the performance on this is so sluggish. lol
(defun C:count_table (/ acmcol adoc clsname keyname
newstyleobj tbldict tblstylename)
(vl-load-com)
(or adoc
(setq adoc
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(setq tbldict
(vla-item
(vla-get-dictionaries
(vla-get-database adoc)
)
"Acad_TableStyle"
)
)
;; look in the tablestyle dictionary to search for our style name:
(if (vl-catch-all-error-p
(setq tbstyleObj (vl-catch-all-apply
(function (lambda()
(vla-item tbldict "Count"))))));change table style name here
;; if table style "TblStyleName" does not exist:
(progn
(setq keyname "NewStyle"
clsname "AcDbTableStyle"
tblstylename "Count" ;change table style name here
)
(setq newstyleobj
(vlax-invoke tbldict 'Addobject keyname clsname)
)
(setq acmcol (vla-GetInterfaceObject
(vlax-get-acad-object)
(strcat "AutoCAD.AcCmColor." (itoa (atoi(getvar "acadver"))))
)
)
;;(vlax-put acmcol 'Colorindex 121)
(vlax-put newstyleobj 'Name TblStyleName)
(vlax-put newstyleobj 'Description "Your description here")
;or use style name as the description
(vlax-put newstyleobj 'HorzCellMargin 3.00) ;;0.06
(vlax-put newstyleobj 'VertCellMargin 3.00) ;;0.06
(vlax-put newstyleobj 'TitleSuppressed :vlax-false)
(vlax-put newstyleobj 'HeaderSuppressed :vlax-false)
(vlax-invoke newstyleobj 'SetColor acDataRow acmcol)
(vlax-invoke newstyleobj
'SetBackgroundColorNone
acDataRow
:vlax-false
)
(vlax-invoke newstyleobj 'SetTextStyle acDataRow "Standard");change textstyle name here
(vlax-invoke newstyleobj 'SetTextHeight acTitleRow 4.00) ;;0.25
(vlax-invoke newstyleobj 'SetTextHeight acHeaderRow 3.00) ;;0.20
(vlax-invoke newstyleobj 'SetTextHeight acDataRow 3.00) ;;0.18
(vlax-invoke newstyleobj 'SetGridVisibility acVertInside acDataRow :vlax-true)
(vlax-invoke newstyleobj
'SetAlignment
acDataRow
acMiddleCenter
)
;| ETC add another options here|;
)
;;inform user if style exist:
;;(princ "\n\t\t ***\tStyle already exist\t***")
)
(SETVAR "CTABLESTYLE" "Count")
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(vl-load-com)
(defun C:CountTB ()
;;(command "UNDO" "B")
;Setup the Table Style
(C:Count_Table)
;;(Alert "Select Dynamic Block(s) to Burst First.")
(command "aecselectsimilar" (ssget "_x" '((0 . "INSERT")(2 . "`*U*"))) "" )
(c:pburst)
(Alert "Select the Block(s) to isolate and it will select all similar blocks.")
;Select Similar Blocks
(command "aecselectsimilar" (ssget) "" )
;isolateobjects
(command "_isolateobjects" "p" "")
;Apply Block Counter
(Alert "Select All Block(s) to be counted.")
(C:COUNT)
;Copy Last (Block Count Table) Original Coordinates
(command "_copybase" "0,0" "last" "")
;Undo the command
(initcommandversion 2)
(command ".undo" "10")
;;(command "UNDO" "B")
;paste original coordinates
(command "_pasteclip" "0,0")
(command "_regenall")
(princ))