Program to pull attribute data from a title block to create a drawing list.

Program to pull attribute data from a title block to create a drawing list.

gv6823otG42ZL
Enthusiast Enthusiast
537 Views
6 Replies
Message 1 of 7

Program to pull attribute data from a title block to create a drawing list.

gv6823otG42ZL
Enthusiast
Enthusiast

Hi community,

In order for me to create a drawing list for a project, I currently need to open each drawing up, and look at the attributes within the title block and then copy the drawing number, the sheet number, and the revision number into a row within the drawing list and then define which group within the company receives a copy of that drawing. All the "1" next to each drawing type are standard, so 01D's always gets sent to those specific groups, and so fourth.  I know the basics of programming within AutoCAD, but is anyone able to create a program that pulls this data from the title block and then places that information within a row on the drawing list? I have attached an excel drawing list and a couple dwg's to play-around with.

gv6823otG42ZL_2-1748527665988.png

 

gv6823otG42ZL_3-1748528215093.png

Please reach out with any questions, or if this is even possible!

 

Thanks!

 

 

0 Likes
538 Views
6 Replies
Replies (6)
Message 2 of 7

Sea-Haven
Mentor
Mentor

I have make a dwg index for a single dwg, but as your using multiple dwgs and reading attributes from different dwg's you need to use OBDX, it allows you to read information even from dwg's not open. 

 

You have provided 2 sample dwg's with only a single title block in each dwg. Do you use layouts ? Looking at the Xl you have a lot of sheets are every one of these a separate individual dwg ? The easy part is reading a known block name.

 

Please explain more how your dwg's are set up.

 

 

0 Likes
Message 3 of 7

gv6823otG42ZL
Enthusiast
Enthusiast

Yes, every Title blocks block name will be that TAD 15, and each block contains the same attributes. All the sheets are there own individual dwg, so 01D SH 1 and 01D SH 2 are 2 completely separate drawings. That excel file is an example of what a drawing list might look like, but that's one specific project. Every project is going to have different drawing names, for each site but follow the basic convention of how we call our drawings outs. We do 99.99% of our work in model space. We don't use any of the other layouts to draft/design and never work in paper space! I have included some more dwg's as well as another example of a drawing list from a previous project for some more understanding! @Sea-Haven 

 

Thanks,

0 Likes
Message 4 of 7

Sea-Haven
Mentor
Mentor

Just to let you know still working on it, but getting somewhere using OBDX. Found a way to get the block from model space, it may not be fast but is faster than say use a script and open dwgs.

 

Please try this it should make a big list of all the attributes tagname and value. You just need to pick any dwg in the directory you want to look in. Dont need dwg's open that is why using OBDX which can read closed dwg's.

 

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/program-to-pull-attribute-data-from-a-title-block-to-create-a/td-p/13656260

(defun c:dwgindex ( / doatts dbx dirpath dwglst lst lst2)

(defun doatts (objb curdwg / )
  (setq lst2 '())
  (setq lst2 (cons (list curdwg (vlax-get objb 'name)) lst2))
  (setq atts (vlax-invoke obj 'Getattributes))
  (setq x (length atts))
  (foreach att atts
    (setq tagname(vlax-get att 'tagstring))
    (setq txt (vlax-get att 'textstring))
    (setq lst2 (cons (list tagname txt) lst2))
  )
  (setq lst (cons (reverse lst2) lst))
)

(setq dbx
  (vl-catch-all-apply 'vla-getinterfaceobject
    (list (setq app (vlax-get-acad-object))
      (if (< (setq vrs (atoi (getvar 'acadver))) 16)
      "objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs))
      )
    )
  )
)

(setq dirpath (getfiled "Pts FILES" "d:\\" "dwg" 16))
(setq dirpath (car (fnsplitl dirpath)))
(setq dwglst (vl-directory-files DirPath "*.dwg" 1))

(setq lst '())
(foreach newdwg dwglst
  (vla-open dbx (strcat dirpath newdwg))
  (setq msobj (vla-get-modelspace dbx))
  (setq x -1)
  (repeat (vlax-get msobj 'count)
   (setq obj (vla-item msobj (setq x (1+ x))))
   (setq obname (vlax-get obj 'objectname))
   (if (and (= obname "AcDbBlockReference")
       (or (=  (vlax-get obj 'name) "TAD15")(=  (vlax-get obj 'name) "TAE15"))
  	   )
   (doatts obj newdwg)
  )
  )
)
(princ lst)

(if (= 'vla-object (type dbx))
    (vlax-release-object dbx)
)
(princ)
)
(c:dwgindex)

Next step is write to EXCEL I don't have a problem with that just need to work out what goes where. can you do a Excel matching the 4 dwgs provided ?

0 Likes
Message 5 of 7

Sea-Haven
Mentor
Mentor

As I asked alread,  your Excel provided is to complex to work out what goes where, need a sample XL matching the provided dwgs.

0 Likes
Message 6 of 7

gv6823otG42ZL
Enthusiast
Enthusiast

@Sea-Haven I Apologize! I didn't see your previous response. Here would be an example of a drawing list using the above 4 DWG's. The Site ID's would be in numerical order, starting with the smallest Site ID and the smallest drawing series, S021-01E SH 1 Rev 29, and then increasing in each category. So S021-20D would come next, S271 -01D SH 1 after that, etc... Let me know if you need anything additional!

0 Likes
Message 7 of 7

gv6823otG42ZL
Enthusiast
Enthusiast

@Sea-Haven Here is another example of one I did super recently for another project at a different site. Once again, took the information directly from the dwg files.

 

0 Likes