nunleym Posted September 25, 2008 Share Posted September 25, 2008 I am new to vba and i am trying to extract a drawings file properties (without opening it) from an open drawing. Is there a way to do this? thanks, mike Quote Link to comment Share on other sites More sharing options...
tzframpton Posted September 25, 2008 Share Posted September 25, 2008 I am new to vba and i am trying to extract a drawings file properties (without opening it) from an open drawing. Is there a way to do this? thanks, mike Could you be more specific?? Do you mean entity properties, or drawing properties such as Layers, Styles, etc? Quote Link to comment Share on other sites More sharing options...
nunleym Posted September 25, 2008 Author Share Posted September 25, 2008 properties such as Title, subject, and custom props that have been defined. thanks for the read Quote Link to comment Share on other sites More sharing options...
Dipali Posted September 25, 2008 Share Posted September 25, 2008 also explore design centre options Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 25, 2008 Share Posted September 25, 2008 I am new to vba and i am trying to extract a drawings file properties (without opening it) from an open drawing. You can to use ObjectDBX interface. For example function (without any error prevention!) to read document comments without document opening in AutoCAD (type something in Drawing Properties...>Summary Tab>Comments). Function Get_Drawing_Info(Drawing As String) Dim Acad As Object Dim dbxDoc As Object Dim dInfo As AcadSummaryInfo Set Acad = ThisDrawing.Application Set dbxDoc = Acad.GetInterfaceObject("ObjectDBX.AxDbDocument.17") dbxDoc.Open (Drawing) Set dInfo = dbxDoc.SummaryInfo MsgBox "This is doc info: " & dInfo.Comments Set dInfo = Nothing Set dbxDoc = Nothing Set Acad = Nothing End Function Test for "Drawing1.dwg". Sub Test() Get_Drawing_Info ("C:\Documents and Settings\Alexander\My Documents\Drawing1.dwg") End Sub Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 25, 2008 Share Posted September 25, 2008 With ObjectDBX you can access to all drawing database objects without drawing opening. Quote Link to comment Share on other sites More sharing options...
rocheey Posted September 25, 2008 Share Posted September 25, 2008 With ObjectDBX you can access to all drawing database objects without drawing opening. Well, actually, you cant read anything out of any document without opening it with some application or other. Whether its a windows .dll, ObjectDBX, or .tlb in VB to read the structured storage (which is the part of the document that stores the extended file properties), there has to be code to open the file. Im not talking about the basic info, which is/can be stored in the file system, but the application specific info. Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 25, 2008 Share Posted September 25, 2008 > rocheey Well, actually, you cant read anything out of any document without opening it with some application or other. Whether its a windows .dll, ObjectDBX, or .tlb in VB to read the structured storage (which is the part of the document that stores the extended file properties), there has to be code to open the file. I mean without file opening in AutoCAD. With ObjectDBX you have access to inner structure of *.dwg files (entities, layers, dictionaries, etc.) but much more fast than with open and close it in AutoCAD. ObjectDBX - isn't AutoCAD or part of AutoCAD it is special COM intrface. You can use it for free from AutoCAD or pay license to use with other applications. Quote Link to comment Share on other sites More sharing options...
nunleym Posted September 25, 2008 Author Share Posted September 25, 2008 thanks for the responses but i have no idea were to begin w/ ObjectDBX. I have a vlisp routine that will serve as a front end and apply the xtracted information to the block that will be inserted. To use the ObjectDBX solution I would need some additional instruction. Frankly, I don't even know enough about it to ask an intelligent question. Thank You very much mike Quote Link to comment Share on other sites More sharing options...
nunleym Posted September 26, 2008 Author Share Posted September 26, 2008 this is what i have so far but if it is possible i want a "silent load" of the drawing. Is this possible? (defun c:gdata () (setq filename (getfiled "SELECT REFERENCE" "t:\\" "DWG" 4)) (setq #dwgfile (vla-open (vla-get-documents (vlax-get-acad-object)) filename :VLAX-false)) (setq #summary_info (vlax-get-property #dwgfile "summaryinfo")) (vlax-dump-object #summary_info t) (vla-close #dwgfile) ) thanks, Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 26, 2008 Share Posted September 26, 2008 I am new to vba and i am trying to extract a drawings file properties (without opening it) from an open drawing. Is there a way to do this? You ask for VBA code but use Visual LISP? Ok you can to use lisp with ObjectDBX (it seems Acad 2007 use "ObjectDBX.AxDbDocument.16"): (defun c:rInfo(/ dDbx cFile iObj i cKey cVal) (vl-load-com) (setq dDbx(vla-getinterfaceobject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument.17"))) (if(setq cFile(getfiled "Select *.dwg file" "t:\\" "dwg" 4)) (progn (vlax-invoke dDBX 'Open cFile) (setq iObj(vla-get-summaryinfo dDbx) i 0); end setq (princ "\n=================== DRAWING INFO REPORT ===================\n") (princ(strcat "\n Full path: " cFile)) (princ(strcat "\n Title: " (vla-get-Title iObj))) (princ(strcat "\n Subject: " (vla-get-Subject iObj))) (princ(strcat "\n Author: " (vla-get-Author iObj))) (princ(strcat "\n Keywords: " (vla-get-Keywords iObj))) (princ(strcat "\n Comments: " (vla-get-Comments iObj))) (princ "\n\n___________________ CUSTOM PROPERTIES ____________________\n") (while(not(vl-catch-all-error-p (vl-catch-all-apply 'vla-GetCustomByIndex (list iObj i 'cKey 'cVal)))) (setq i(1+ i)) (if cKey (princ(strcat "\n " cKey ": " cVal)) ); end if (setq cKey nil cVal nil) ); end while (princ "\n\n======================= END REPORT =======================") (textscr) ); end progn ); end if (vlax-release-object dDbx) (princ) ); end of c:rInfo Without any checkups Compare working speed between opening file in inactive mode and ObjectDBX usage :wink: Command: rinfo =================== DRAWING INFO REPORT =================== Full path: C:\Documents and Settings\Administrator\My Documents\Drawing1.dwg Title: Sample drawing Subject: Balck screen Author: ASMI Keywords: Bla, bla, bla Comments: Testing of c:rInfo code ____________________ CUSTOM PROPERTIES ____________________ Some property: Some value Another property: Another value ======================= END REPORT ======================= Quote Link to comment Share on other sites More sharing options...
nunleym Posted September 26, 2008 Author Share Posted September 26, 2008 thank you ASMI that is exactly what i am after. thank you the reason I started this as a vba question was I knew i couldnt get there w/ straight vlisp and thought that vba was the way to go. thank you for your help and patience Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 27, 2008 Share Posted September 27, 2008 the reason I started this as a vba question was I knew i couldnt get there w/ straight vlisp and thought that vba was the way to go. All possibilities of AutoCAD VBA are accessible in Visual LISP, but not all possibilities of LISP are accessible in VBA. Quote Link to comment Share on other sites More sharing options...
rocheey Posted September 29, 2008 Share Posted September 29, 2008 I am new to vba and i am trying to extract a drawings file properties (without opening it) from an open drawing. Is there a way to do this? thanks, mike start a new project, and add a reference to ObjectDBX :Click "Tools", "References", then select "AutoCad/ObjectDBX Common 17.0 Type Library" . if you dont have version 17, select the one with the highest number available. Paste the following code into a code module: Sub DwgInfo() Dim objAxDoc As AXDBLib.AxDbDocument objAxDoc.Open ("c:\BAD_DRAWERS.dwg") MsgBox "*" & objAxDoc.SummaryInfo.Author & "*" Set objAxDoc = Nothing End Sub you can get different params by erasing the ".Author", and when you retype the missing "." a list of available summary info items will be listed. This should get you started Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.