Obtaining CAD drawing data from an unopened drawing.

Obtaining CAD drawing data from an unopened drawing.

Anonymous
Not applicable
551 Views
8 Replies
Message 1 of 9

Obtaining CAD drawing data from an unopened drawing.

Anonymous
Not applicable
How can I get the drawing data from an unopened CAD document in VBA?
My goal is to have a form with a listbox of the files in the current
directory folder, and when a user clicks on a file in the listbox, another
listbox is populated with the names of the layouts in that drawing.
I've been unsuccessful in accessing this information unless the file is
currently open. I know that I could create a second instance of AutoCAD,
open the selected file in the background, populate the listbox with the
thisdrawing.layouts property and then quit the second running ACAD object,
but that's really memory and time intensive, and I'm sure there's another
way, because ADT 2002's Design Center Explorer can do this very thing.
Any help anyone can give me would be much appreciated. Thanks in
advance!

Kevin Mullinax
0 Likes
552 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
ObjectDbx

"Kevin Mullinax" wrote in message
news:8C50BD4B7B5BB67AC006ECE9644B55D1@in.WebX.maYIadrTaRb...
> How can I get the drawing data from an unopened CAD document in VBA?
0 Likes
Message 3 of 9

Anonymous
Not applicable
to elaborate slightly..

"Mark Propst" wrote in message
news:B8B464DF43DF35B8B122AC89DC5344A0@in.WebX.maYIadrTaRb...
> ObjectDbx
>

Option Explicit

'must have reference to ObjectDBX 1.0 Type Library set in Tools|References
'object dbx must be registered on each computer on which this sub is to run

' Based on example by Jimmy B 2000-03-08
' Runs in AutoCAD 2000 with axdb15.dll (must be referenced)
' Example of listing all layouts on all drawings in a directory.
' prints filename and layout names to textscreen of current document

Private Sub ListLayouts()
Dim oDbx As AxDbDocument
Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument")
Dim oLyt As AXDB15Lib.AcadLayout

Dim sPath As String
Dim sFileName As String
Dim sFullName As String

'******** put your path here *********
'sPath = "C:\DirectoryWithDrawingFiles"

sFileName = Dir$(sPath & "\*.dwg")

Do While sFileName <> ""
ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) / 2, "-") &
"Layout list for" & String(Len(sFileName) / 2, "-")
ThisDrawing.Utility.Prompt vbCrLf & "File: " & sFileName
ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) + 15, "-")
sFullName = sPath & "\" & sFileName
On Error Resume Next
oDbx.Open sFullName
If Err Then
'drawing probably needs recovery
ThisDrawing.Utility.Prompt vbCrLf & sFullName & " *** unable to
open ***"
Err.Clear
Else
For Each oLyt In oDbx.Layouts
ThisDrawing.Utility.Prompt vbCrLf & oLyt.Name
Next
End If
Set oLyt = Nothing
sFileName = Dir$
ThisDrawing.Utility.Prompt vbCrLf
Loop
Set oDbx = Nothing
End Sub
0 Likes
Message 4 of 9

Anonymous
Not applicable
Thanks a lot for your help - I'll give that a shot.

"Mark Propst" wrote in message
news:71C72862EC2CD0644935F9FB4531888D@in.WebX.maYIadrTaRb...
> to elaborate slightly..
>
> "Mark Propst" wrote in message
> news:B8B464DF43DF35B8B122AC89DC5344A0@in.WebX.maYIadrTaRb...
> > ObjectDbx
> >
>
> Option Explicit
>
> 'must have reference to ObjectDBX 1.0 Type Library set in Tools|References
> 'object dbx must be registered on each computer on which this sub is to
run
>
> ' Based on example by Jimmy B 2000-03-08
> ' Runs in AutoCAD 2000 with axdb15.dll (must be referenced)
> ' Example of listing all layouts on all drawings in a directory.
> ' prints filename and layout names to textscreen of current document
>
> Private Sub ListLayouts()
> Dim oDbx As AxDbDocument
> Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument")
> Dim oLyt As AXDB15Lib.AcadLayout
>
> Dim sPath As String
> Dim sFileName As String
> Dim sFullName As String
>
> '******** put your path here *********
> 'sPath = "C:\DirectoryWithDrawingFiles"
>
> sFileName = Dir$(sPath & "\*.dwg")
>
> Do While sFileName <> ""
> ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) / 2, "-") &
> "Layout list for" & String(Len(sFileName) / 2, "-")
> ThisDrawing.Utility.Prompt vbCrLf & "File: " & sFileName
> ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) + 15, "-")
> sFullName = sPath & "\" & sFileName
> On Error Resume Next
> oDbx.Open sFullName
> If Err Then
> 'drawing probably needs recovery
> ThisDrawing.Utility.Prompt vbCrLf & sFullName & " *** unable
to
> open ***"
> Err.Clear
> Else
> For Each oLyt In oDbx.Layouts
> ThisDrawing.Utility.Prompt vbCrLf & oLyt.Name
> Next
> End If
> Set oLyt = Nothing
> sFileName = Dir$
> ThisDrawing.Utility.Prompt vbCrLf
> Loop
> Set oDbx = Nothing
> End Sub
>
>
>
>
>
>
0 Likes
Message 5 of 9

Anonymous
Not applicable
Can I use Objectdbx in AutoCAD 2002?



"Kevin Mullinax" wrote in message
news:8C50BD4B7B5BB67AC006ECE9644B55D1@in.WebX.maYIadrTaRb...
> How can I get the drawing data from an unopened CAD document in VBA?
> My goal is to have a form with a listbox of the files in the current
> directory folder, and when a user clicks on a file in the listbox, another
> listbox is populated with the names of the layouts in that drawing.
> I've been unsuccessful in accessing this information unless the file
is
> currently open. I know that I could create a second instance of AutoCAD,
> open the selected file in the background, populate the listbox with the
> thisdrawing.layouts property and then quit the second running ACAD object,
> but that's really memory and time intensive, and I'm sure there's another
> way, because ADT 2002's Design Center Explorer can do this very thing.
> Any help anyone can give me would be much appreciated. Thanks in
> advance!
>
> Kevin Mullinax
>
>
0 Likes
Message 6 of 9

Anonymous
Not applicable
Ok, I tried what you suggested, but I'm getting this error message upon
running the routine.

Run-time error (***error-code***)
Problem in loading application.

I have the Object DBX referenced into VBA, so I'm not sure what the problem
is... any ideas?
Thanks again for any help...

Kevin Mullinax

"Mark Propst" wrote in message
news:71C72862EC2CD0644935F9FB4531888D@in.WebX.maYIadrTaRb...
> to elaborate slightly..
>
> "Mark Propst" wrote in message
> news:B8B464DF43DF35B8B122AC89DC5344A0@in.WebX.maYIadrTaRb...
> > ObjectDbx
> >
>
> Option Explicit
>
> 'must have reference to ObjectDBX 1.0 Type Library set in Tools|References
> 'object dbx must be registered on each computer on which this sub is to
run
>
> ' Based on example by Jimmy B 2000-03-08
> ' Runs in AutoCAD 2000 with axdb15.dll (must be referenced)
> ' Example of listing all layouts on all drawings in a directory.
> ' prints filename and layout names to textscreen of current document
>
> Private Sub ListLayouts()
> Dim oDbx As AxDbDocument
> Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument")
> Dim oLyt As AXDB15Lib.AcadLayout
>
> Dim sPath As String
> Dim sFileName As String
> Dim sFullName As String
>
> '******** put your path here *********
> 'sPath = "C:\DirectoryWithDrawingFiles"
>
> sFileName = Dir$(sPath & "\*.dwg")
>
> Do While sFileName <> ""
> ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) / 2, "-") &
> "Layout list for" & String(Len(sFileName) / 2, "-")
> ThisDrawing.Utility.Prompt vbCrLf & "File: " & sFileName
> ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) + 15, "-")
> sFullName = sPath & "\" & sFileName
> On Error Resume Next
> oDbx.Open sFullName
> If Err Then
> 'drawing probably needs recovery
> ThisDrawing.Utility.Prompt vbCrLf & sFullName & " *** unable
to
> open ***"
> Err.Clear
> Else
> For Each oLyt In oDbx.Layouts
> ThisDrawing.Utility.Prompt vbCrLf & oLyt.Name
> Next
> End If
> Set oLyt = Nothing
> sFileName = Dir$
> ThisDrawing.Utility.Prompt vbCrLf
> Loop
> Set oDbx = Nothing
> End Sub
>
>
>
>
>
>
0 Likes
Message 7 of 9

Anonymous
Not applicable
Yes, but you need to register the .dll file. Enter the following at Windows
(not AutoCad) command prompt (hit enter at the end of each line):

c:
cd "program files\autodesk architectural desktop 3"
RegSvr32.exe AxDb15.dll


"Dirkasaurus" wrote in message
news:044911E686E764EF5218CC8B57907EFA@in.WebX.maYIadrTaRb...
> Can I use Objectdbx in AutoCAD 2002?
>
>
>
> "Kevin Mullinax" wrote in message
> news:8C50BD4B7B5BB67AC006ECE9644B55D1@in.WebX.maYIadrTaRb...
> > How can I get the drawing data from an unopened CAD document in VBA?
> > My goal is to have a form with a listbox of the files in the current
> > directory folder, and when a user clicks on a file in the listbox,
another
> > listbox is populated with the names of the layouts in that drawing.
> > I've been unsuccessful in accessing this information unless the file
> is
> > currently open. I know that I could create a second instance of
AutoCAD,
> > open the selected file in the background, populate the listbox with the
> > thisdrawing.layouts property and then quit the second running ACAD
object,
> > but that's really memory and time intensive, and I'm sure there's
another
> > way, because ADT 2002's Design Center Explorer can do this very thing.
> > Any help anyone can give me would be much appreciated. Thanks in
> > advance!
> >
> > Kevin Mullinax
> >
> >
>
>
0 Likes
Message 8 of 9

Anonymous
Not applicable
You may need to register the objectDBX dll. Enter these lines at the Windows
(not AutoCad) command prompt(hit enter at the end of each line):

c:
cd "program files\autodesk architectural desktop 3"
RegSvr32.exe AxDb15.dll



"Kevin Mullinax" wrote in message
news:F719BE447C3464284000F6A47F875A6A@in.WebX.maYIadrTaRb...
> Ok, I tried what you suggested, but I'm getting this error message upon
> running the routine.
>
> Run-time error (***error-code***)
> Problem in loading application.
>
> I have the Object DBX referenced into VBA, so I'm not sure what the
problem
> is... any ideas?
> Thanks again for any help...
>
> Kevin Mullinax
>
> "Mark Propst" wrote in message
> news:71C72862EC2CD0644935F9FB4531888D@in.WebX.maYIadrTaRb...
> > to elaborate slightly..
> >
> > "Mark Propst" wrote in message
> > news:B8B464DF43DF35B8B122AC89DC5344A0@in.WebX.maYIadrTaRb...
> > > ObjectDbx
> > >
> >
> > Option Explicit
> >
> > 'must have reference to ObjectDBX 1.0 Type Library set in
Tools|References
> > 'object dbx must be registered on each computer on which this sub is to
> run
> >
> > ' Based on example by Jimmy B 2000-03-08
> > ' Runs in AutoCAD 2000 with axdb15.dll (must be referenced)
> > ' Example of listing all layouts on all drawings in a directory.
> > ' prints filename and layout names to textscreen of current document
> >
> > Private Sub ListLayouts()
> > Dim oDbx As AxDbDocument
> > Set oDbx = GetInterfaceObject("ObjectDBX.AxDbDocument")
> > Dim oLyt As AXDB15Lib.AcadLayout
> >
> > Dim sPath As String
> > Dim sFileName As String
> > Dim sFullName As String
> >
> > '******** put your path here *********
> > 'sPath = "C:\DirectoryWithDrawingFiles"
> >
> > sFileName = Dir$(sPath & "\*.dwg")
> >
> > Do While sFileName <> ""
> > ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) / 2, "-")
&
> > "Layout list for" & String(Len(sFileName) / 2, "-")
> > ThisDrawing.Utility.Prompt vbCrLf & "File: " & sFileName
> > ThisDrawing.Utility.Prompt vbCrLf & String(Len(sFileName) + 15, "-")
> > sFullName = sPath & "\" & sFileName
> > On Error Resume Next
> > oDbx.Open sFullName
> > If Err Then
> > 'drawing probably needs recovery
> > ThisDrawing.Utility.Prompt vbCrLf & sFullName & " *** unable
> to
> > open ***"
> > Err.Clear
> > Else
> > For Each oLyt In oDbx.Layouts
> > ThisDrawing.Utility.Prompt vbCrLf & oLyt.Name
> > Next
> > End If
> > Set oLyt = Nothing
> > sFileName = Dir$
> > ThisDrawing.Utility.Prompt vbCrLf
> > Loop
> > Set oDbx = Nothing
> > End Sub
> >
> >
> >
> >
> >
> >
>
>
0 Likes
Message 9 of 9

Anonymous
Not applicable
Tony,

I do have the AxDb15.dll file in my AutoCad Map5 directory.. I am assuming
that I can register it the same way? And is there any documentation for
Objectdbx in Map 5. I didn't find any in acad_dev.chm


"Tony Burba" wrote in message
news:393D3A7B125AF62D3117AF573E47FBCA@in.WebX.maYIadrTaRb...
> Yes, but you need to register the .dll file. Enter the following at
Windows
> (not AutoCad) command prompt (hit enter at the end of each line):
>
> c:
> cd "program files\autodesk architectural desktop 3"
> RegSvr32.exe AxDb15.dll
>
>
> "Dirkasaurus" wrote in message
> news:044911E686E764EF5218CC8B57907EFA@in.WebX.maYIadrTaRb...
> > Can I use Objectdbx in AutoCAD 2002?
> >
> >
> >
> > "Kevin Mullinax" wrote in message
> > news:8C50BD4B7B5BB67AC006ECE9644B55D1@in.WebX.maYIadrTaRb...
> > > How can I get the drawing data from an unopened CAD document in
VBA?
> > > My goal is to have a form with a listbox of the files in the
current
> > > directory folder, and when a user clicks on a file in the listbox,
> another
> > > listbox is populated with the names of the layouts in that drawing.
> > > I've been unsuccessful in accessing this information unless the
file
> > is
> > > currently open. I know that I could create a second instance of
> AutoCAD,
> > > open the selected file in the background, populate the listbox with
the
> > > thisdrawing.layouts property and then quit the second running ACAD
> object,
> > > but that's really memory and time intensive, and I'm sure there's
> another
> > > way, because ADT 2002's Design Center Explorer can do this very thing.
> > > Any help anyone can give me would be much appreciated. Thanks in
> > > advance!
> > >
> > > Kevin Mullinax
> > >
> > >
> >
> >
>
>
0 Likes