TheSwamp
Code Red => .NET => Topic started by: Fred Tomke on April 11, 2011, 06:44:04 PM
-
Hello,
I can get the database from the document using
Document oDoc = Application.DocumentManager.MdiActiveDocument;
Database oDb = oDoc.Database
I can get the database from a database resistent entity using
Entity oEnt;
Database oDb = oEnt.Database;
But how can I get the document where the entity was created in?
In VisualLisp there was a (vla-get-document oLine);
Thanks and regards,
Fred
-
Look into this:
Document oDoc = Application.DocumentManager.GetDocument(oDb);
-
Hello Fred,
As Jeff Indicated ;
// CodeHimBelonga kdub@theSwamp 20110412
// http://www.theswamp.org/index.php?topic=37860.msg428862#msg428862
using System;
using System.IO;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
//
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AcUtils = Autodesk.AutoCAD.Internal.Utils;
[assembly: CommandClass(typeof(KdubTesting.WhoIsYouDaddy))]
namespace KdubTesting
{
public class WhoIsYouDaddy
{
[CommandMethod("DADDY_1")]
public void WhoIsYouDaddy_1()
{
Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult peResult = ed.GetEntity("\nSelect an entity: ");
if( peResult.Status != PromptStatus.OK )
return;
Document daddyDoc = WhoIsYourDaddyO(peResult.ObjectId);
if( daddyDoc != null ) {
ed.WriteMessage(daddyDoc.Name.ToString());
}
}
/// <summary>
/// Determine the Document ( Owner ) of objID
/// </summary>
/// <param name="objID"> ObjectId </param>
/// <returns>Document </returns>
private static Document WhoIsYourDaddyO(ObjectId objID)
{
Document oDoc = Application.DocumentManager.GetDocument(objID.Database);
return oDoc;
}
}
}
-
Hi guys,
I was sure that there is a method for this.
Thank you!
Fred