Jump to content

Access A Drawings File Properties From Another Drawing


nunleym

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

> 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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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 =======================

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...