TheSwamp
Code Red => .NET => Topic started by: sdunn on September 24, 2018, 03:47:00 PM
-
I am working with Civil 3D survey figures and I need to access a property that is not available in the .net api. The property is available through COM. Are there any methods available to get a COM version of a .Net object? So far the only information I have found is to get the .AcadObject from the entity I am working with.
Dim survFig as Autodesk.Civil.DatabaseServices.SurveyFigure
survFig = TryCast(trans.GetObject(Oid, OpenMode.ForWrite), SurveyFigure)
Dim oSurvFig As Autodesk.AECC.Interop.Survey.AeccSurveyFigure
oSurvFig = TryCast(survFig.AcadObject, AeccSurveyFigure)
The problem I am having is the .AcadObject of survFig is Aeccfeatureline and not AeccSurveyFigure. Is there a step I am missing or another method to get the COM version of the same object or perhaps make the COM properties available to the .net object?
Thank you,
Stacy
-
Hmm, your code looks right, you might try AcadDocument.ObjectIdToObject or AcadDocument.HandleToObject
-
something like
public class Commands
{
static object getComDbObj(ObjectId id, Document doc)
{
AcadDocument acadDocument = doc.GetAcadDocument() as AcadDocument;
if (acadDocument == null)
throw new System.Exception("AcadDocument is null");
return acadDocument.ObjectIdToObject(id.OldId);
}
[CommandMethod("doit")]
public static void doit()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
AcadModelSpace ms = getComDbObj(doc.Database.CurrentSpaceId, doc) as AcadModelSpace; //assume
doc.Editor.WriteMessage(ms == null ? "null" : "eOk");
}
}
-
Thank you for the suggestions. I still get the featureline object and subsequent cast error when using id.OldIdptr to get the COM ObjectID from the .net object. I would rather not re-write the routine to work with only the COM version, but that looks like the route I am headed down.