.NET

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

How to open database from an open drawing

178 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: 9,217
Registered: ‎06-29-2007
Message 2 of 5 (176 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: 1,021
Registered: ‎04-27-2009
Message 3 of 5 (162 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 (160 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 (152 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

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