.NET

.NET

Reply
Contributor
22 Posts
0 Kudos
Registered: ‎08-25-2012
Post 1 of 5

How to open database from an open drawing

189 Views, 4 Replies
08-26-2012 07:05 AM

Once I have the dwg open how do I get to the database?

 

 

 

        Dim AcadApp As Object = Nothing
        Dim AcadDoc As Object = Nothing

        Try
            AcadApp = GetObject(, "AutoCAD.Application.18")
        Catch ex As Exception
            AcadApp = CreateObject("AutoCAD.Application.18")
        End Try

        AcadApp.Visible = False

        Try
            AcadDoc = AcadApp.Documents.Open("C:\Users\PAUL\Desktop\B-03-J-H135.dwg", True)
        Catch ex As Exception
            Exit Sub
        End Try

        Dim MyDb As Database = AcadApp.DocumentManager.MdiActiveDocument.Database

 

*Expert Elite*
9,809 Posts
1,210 Kudos
Registered: ‎06-29-2007
Post 2 of 5

Re: How to open database from an open drawing

08-26-2012 07:11 AM in reply to: phives

Hi,

 

>> Once I have the dwg open how do I get to the database?

You have it, where is the question?

You have it here:

Dim MyDb As Database = AcadApp.DocumentManager.MdiActiveDocument.Database

That <MyDb> is the database of your currently active drawing!

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
*Expert Elite*
1,084 Posts
215 Kudos
Registered: ‎04-27-2009
Post 3 of 5

Re: How to open database from an open drawing

08-26-2012 10:09 AM in reply to: phives

From he code yoy showed (and also the code you showed in previous post), it looks like you are doing Stabdalone EXE apllication.

 

If so, you can forget about setting reference to acdbmgd.dll and acmgd.dll and using APIs exposed in these 2 assemblies: they CANNOT be used outside AutoCAD in a standalone app. End of story.

 

You have to use COM APIs. The code would be sililar to VBA code.

Contributor
22 Posts
0 Kudos
Registered: ‎08-25-2012
Post 4 of 5

Re: How to open database from an open drawing

08-26-2012 10:18 AM in reply to: norman.yuan

Well then tell me how. Because there are other apps out there doing what I need to do. According to the docs from ACAD, that is what those DLL's are for.

*Expert Elite*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 5 of 5

Re: How to open database from an open drawing

08-26-2012 11:32 AM in reply to: phives

As you're mentioned above you HAVE NOT use dll libraries

in your .exe aplppliction at all,

so forget about them, indeed

Use just VBA like syntax and nothiing else, in the short words

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!