different Between Database definitions

different Between Database definitions

Amremad
Collaborator Collaborator
993 Views
3 Replies
Message 1 of 4

different Between Database definitions

Amremad
Collaborator
Collaborator

what's the different between

 

 Dim oDb As Database = HostApplicationServices.WorkingDatabase

 and

 

Dim oDb As Database = Application.DocumentManager.MdiActiveDocument.Database

and

Dim oDb As Database = Application.DocumentManager.MdiActiveDocument.Editor.Document.Database

 

0 Likes
994 Views
3 Replies
Replies (3)
Message 2 of 4

DiningPhilosopher
Collaborator
Collaborator

In AutoCAD they return the same value.

 

HostApplicationServices is a way to access certain functions in non-AutoCAD host applications (e.g,. RealDWG), where there is no Document object.

Message 3 of 4

Anonymous
Not applicable

Autodesk.AutoCAD.ApplicationServices.Application is a class from assembly acmgd.dll which references acdbmgd.dll

 

Autodesk.AutoCAD.DatabaseServices.HostApplicationServices is a class from acdbmgd.dll

 

Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase is the active working database of the single-threaded RealDWG process, which is an engine of AutoCAD without UI.

 

In AutoCAD, Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase is a pointer of Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database. So every time you change the active drawing on AutoCAD, it will set MdiActiveDocument.Database to WorkingDatabase. There are many MdiActiveDocument.Databases in DocumentManager, but there is only one WorkingDatabase which is a worker of MdiActiveDocument.Database.

 

In short, all AutoCAD database tasks are based on RealDWG engine, MdiActiveDocument.Database is an upper layer of WorkingDatabase.

 

You also see the another answer at the link.

 

-Khoa

www.netscriptcad.com

 

Message 4 of 4

Anonymous
Not applicable

In short, in AutoCAD:
Application.DocumentManager.MdiActiveDocument.Database calls HostApplicationServices.WorkingDatabase to execute the drawing database job.

MdiActiveDocument.Editor.Document = MdiActiveDocument so MdiActiveDocument.Editor.Document.Database = MdiActiveDocument.Database

In RealDWG, there is only HostApplicationServices.WorkingDatabase