I tried posting this at "the other place", but it doesn't seem to be going anywhere. Maybe someone around here knows the "trick".
I'm trying to get to the Aecc database for Civil-3D - basically, the database for the vertical application. Peter Funk says to do it like this:
Dim blk As AcadExternalReference
Set blk = obj
Dim oapp As AcadApplication
Set oapp = blk.Application
Dim oCivilApp As AeccApplication
Dim oAeccDoc As AeccDocument
Dim oAeccDb As AeccDatabase
Const sAppName = "AeccXUiLand.AeccApplication.6.0"
Set oCivilApp = oapp.GetInterfaceObject(sAppName)
Set oAeccDoc = oCivilApp.ActiveDocument
Set oAeccDb = oAeccDoc.Database
Of course, I'm not doing VBA.
So I try this:
BlockReference br; // my XREF
AcadExternalReference extRef = br.AcadObject as AcadExternalReference;
AcadApplication oApp = (AcadApplication)extRef.Application;
...but that last line crashes on me, with an error HRESULT E_FAIL has been returned by COM object.
Am I mis-interpreting Peter's response? Casting br.AcadObject to an AcadExternalReference seems to work - it returns a com object. But then it fails on the next line, when I try to get to the Application.
Anyone have any idea what's going on here?