.NET

Reply
Contributor
phives
Posts: 22
Registered: ‎08-25-2012
Message 1 of 5 (170 Views)

How to open database from an open drawing

170 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*
Alfred.NESWADBA
Posts: 8,963
Registered: ‎06-29-2007
Message 2 of 5 (168 Views)

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*
norman.yuan
Posts: 983
Registered: ‎04-27-2009
Message 3 of 5 (154 Views)

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
phives
Posts: 22
Registered: ‎08-25-2012
Message 4 of 5 (152 Views)

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*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 5 of 5 (144 Views)

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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.