Jeff
I still can't thank you enough. Hope you don't mind, I've added to you routine the following:
added BrowseForFolder title and info
added AutoCAD's progress bar while routine runs
modified with my title block attribute "2436TBA" with values "A-01" "SHT_TTL"
added reconstruct list coding
added open notepad with sheet list
My next goal is to use excel in lieu of notepad, and fill in cells within the excel file. There are probably some examples out there.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; This original Copyrighted routine has been modified...
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;;function to extract 2 attribute values from a specific block in the drawings of a specified folder
;;;by Jeff Mishler Feb. 9, 2006
;;;
;;;added BrowseForFolder title and info
;;;added AutoCAD's progress bar while routine runs
;;;modified with my title block attribute "2436TBA" with values "A-01" "SHT_TTL"
;;;added reconstruct list coding
;;;added open notepad with sheet list
;;;by Gary Fowler
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun getindex (blkname attname1 attname2 / *acad atts dwgs f folder layouts masterlist name odbx val1 val2 n)
(defun BrowseForFolder (/ sh folder parentfolder folderobject result)
;;as posted the autodesk discussion customization group by Tony Tanzillo
(vl-load-com)
(setq sh
(vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application"
)
)
(setq folder
(vlax-invoke-method
sh 'BrowseForFolder 0 (strcat " SHEET INDEX" "\tSelect drawing location for ''Sheet Files''\n\t\tCreates index of all drawings in folder.\n\t\tBy: Jeff Mishler ©2006") 0)
) ;;added BrowseForFolder title and info
(vlax-release-object sh)
(if folder
(progn
(setq parentfolder
(vlax-get-property folder 'ParentFolder)
)
(setq FolderObject
(vlax-invoke-method
ParentFolder
'ParseName
(vlax-get-property Folder 'Title)
)
)
(setq result
(vlax-get-property FolderObject 'Path)
)
(mapcar 'vlax-release-object
(list folder parentfolder folderobject)
)
result
)
)
)
(defun getdwglist (folderlist)
(apply 'append
(mapcar '(lambda (f)
(mapcar '(lambda (name)
(strcat f "\\" name)
)
(vl-directory-files f "*.dwg" 1)
)
)
folderlist
)
)
)
(if (and (setq *acad (vlax-get-acad-object))
(setq folder (browseforfolder))
(setq dwgs (getdwglist (list folder)))
)
(progn
(setq n 1) ;;added progress bar count marker
(if (member "acetutil.arx" (arx))(ACET-UI-PROGRESS-INIT "Please Wait while the Program is Running" (length dwg))) ;;added progress bar start
(setq
odbx (if (< (atoi (substr (getvar "acadver") 1 2)) 16)
(vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument")
(vla-GetInterfaceObject
*acad
"ObjectDBX.AxDbDocument.16"
)
)
)
(foreach dwg dwgs
;;(ARCH:WORKING) ;;spinner test not used
(if (member "acetutil.arx" (arx))(ACET-UI-PROGRESS-SAFE n)) ;;added progress bar running
(setq n (+ n 1)) ;;added progress bar count marker
(if
(and
(not (vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(vla-open odbx dwg)
)
)
)
)
;see if the block is even in the drawing
(not
(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(setq blk (vla-item (vla-get-blocks odbx) blkname))
)
)
)
)
)
(progn
;;it is...carry on
(setq layouts (vla-get-layouts odbx))
(vlax-for layout layouts
(if (not (eq "MODEL" (strcase (vla-get-name layout))))
(progn
(vlax-for ent (vla-get-block layout)
(if (and (eq (vla-get-objectname ent)
"AcDbBlockReference"
)
(eq (strcase (vla-get-name ent))
(strcase blkname)
)
)
(progn
(setq atts (vlax-invoke ent 'getattributes))
(foreach att atts
(if (eq (vla-get-tagstring att)
(strcase attname1)
)
(setq val1 (vla-get-textstring att))
)
(if (eq (vla-get-tagstring att)
(strcase attname2)
)
(setq val2 (vla-get-textstring att))
)
)
(setq masterlist
(cons (cons val1 val2) masterlist)
;(cons (list (vla-get-name odbx) (cons val1 val2)) masterlist);for testing
)
)
)
)
)
)
)
)
)
)
(mapcar 'vlax-release-object (list odbx *acad))
)
)
(reverse masterlist)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;modified with my title block attribute "TAG" with values "A-01" "SHT_TTL"
;;;added reconstruct list coding
;;;added open notepad with sheet list
(defun ARCH:CreateIndex2436TAG (/ indexlist file)
(setq indexlist (getindex "TAG" "A-01" "SHT_TTL"))
(if (member "acetutil.arx" (arx))(ACET-UI-PROGRESS-DONE)) ;;added progress bar finish
;|
(princ "\n")
(repeat
(length indexlist)
(setq a (car indexlist) indexlist (cdr indexlist))
(princ (car a))
(princ "\t")
(princ (cdr a))
(princ "\n")
)
|;
(setq file (open "C:\\Temp\\SheetIndex.txt" "w"))
(repeat
(length indexlist)
(setq a (car indexlist) indexlist (cdr indexlist))
(write-line (strcat (car a) "\t" (cdr a)) file)
)
(close file)
(command ".shell" "notepad C:\\Temp\\SheetIndex.txt")
)
;;;
(defun ARCH:CreateIndex2436TBA (/ indexlist file)
(setq indexlist (getindex "2436TBA" "A-01" "SHT_TTL"))
(if (member "acetutil.arx" (arx))(ACET-UI-PROGRESS-DONE)) ;;added progress bar finish
;|
(princ "\n")
(repeat
(length indexlist)
(setq a (car indexlist) indexlist (cdr indexlist))
(princ (car a))
(princ "\t")
(princ (cdr a))
(princ "\n")
)
|;
(setq file (open "C:\\Temp\\SheetIndex.txt" "w"))
(repeat
(length indexlist)
(setq a (car indexlist) indexlist (cdr indexlist))
(write-line (strcat (car a) "\t" (cdr a)) file)
)
(close file)
(command ".shell" "notepad C:\\Temp\\SheetIndex.txt")
)
;;;
(defun ARCH:CreateIndex3042TBA (/ indexlist file)
(setq indexlist (getindex "3042TBA" "A-01" "SHT_TTL"))
(if (member "acetutil.arx" (arx))(ACET-UI-PROGRESS-DONE)) ;;added progress bar finish
;|
(princ "\n")
(repeat
(length indexlist)
(setq a (car indexlist) indexlist (cdr indexlist))
(princ (car a))
(princ "\t")
(princ (cdr a))
(princ "\n")
)
|;
(setq file (open "C:\\Temp\\SheetIndex.txt" "w"))
(repeat
(length indexlist)
(setq a (car indexlist) indexlist (cdr indexlist))
(write-line (strcat (car a) "\t" (cdr a)) file)
)
(close file)
(command ".shell" "notepad C:\\Temp\\SheetIndex.txt")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)
;;;(ARCH:CreateIndex2436TAG)
;;;(ARCH:CreateIndex2436TBA)
;;;(ARCH:CreateIndex3042TBA)
[\code]
Gary