.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to open database from an open drawing

4 REPLIES 4
Reply
Message 1 of 5
phives
479 Views, 4 Replies

How to open database from an open drawing

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

 

4 REPLIES 4
Message 2 of 5
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 5
norman.yuan
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.

Message 4 of 5
phives
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.

Message 5 of 5
Hallex
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost