Accessing Title block attributes without open the drawing

Accessing Title block attributes without open the drawing

Anonymous
Not applicable
585 Views
1 Reply
Message 1 of 2

Accessing Title block attributes without open the drawing

Anonymous
Not applicable

I have tried to get the drawing file name and the title of the drawing from block attributes in paperspace. I have written this code but not working. pls help in this regards

(defun c:test ()

(defun *error* (msg)
(if fo
(progn
(close fo)
);progn
);if
);defun error

(setq fo (open "c:\\Lisp\\Drawing Nmae and Number.xls" "w"))

(setq dDbx (vla-getinterfaceobject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." (substr (getvar "acadver") 1 2))))

(setq file-list (vl-directory-files (getvar "dwgprefix") "*.dwg"))

(setq m 0)
(repeat (length file-list)
(setq filename (strcat (getvar "dwgprefix") (nth m file-list)))
(vlax-invoke-method dDBX 'Open filename)
(setq n 0)
(repeat (vla-get-count (vla-get-paperspace (vla-get-database dDBX)))
(setq blk (vla-item (vla-get-paperspace (vla-get-database dDBX)) n))

(if (eq (vla-get-objectname blk) "AcDbBlockReference")
(progn

(if (vlax-property-available-p blk 'effectivename)
(setq nam (vlax-get-property blk 'effectivename))
(setq nam (vlax-get-property blk 'name))
);if

(if (eq nam "TB_ATT")
(progn
(setq fn (vla-get-textstring (nth 57 (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))))
(setq T1 (vla-get-textstring (nth 53 (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))))
(setq T2 (vla-get-textstring (nth 54 (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))))
(setq T3 (vla-get-textstring (nth 55 (vlax-safearray->list (vlax-variant-value (vla-getattributes blk))))))
(setq title (strcat T1" "T2" "T3))
(setq fnt (strcat fn" "title))
(write-line fnt fo)
(setq n (1+ n))
);progn

(progn
(setq n (1+ n))
);progn
);if

);progn

(progn
(setq n (1+ n))
);prgn
);if
);repeat

(setq m (1+ m))
);repeat

(close fo)
);defun

 

Thanks in Advance 

STM

0 Likes
586 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

 Lot to wade through maybe use layouts  with ddbx. Example is current dwg. Replace doc with correct ddbx code.

 

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)

 Side question your opening a excel file name to write to xls did you mean csv or txt.

0 Likes