Code Red > .NET
Digging Into XREFs
sinc:
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:
--- Code: --- 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
--- End code ---
Of course, I'm not doing VBA.
So I try this:
--- Code: ---BlockReference br; // my XREF
AcadExternalReference extRef = br.AcadObject as AcadExternalReference;
AcadApplication oApp = (AcadApplication)extRef.Application;
--- End code ---
...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?
Glenn R:
Something like this maybe?
--- Code: ---using Autodesk.AutoCAD.Interop;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;
...
AcadApplication comAcadApp = acadApp.AcadApplication as AcadApplication;
AeccApplication comAeccApp = comAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.6.0") as AeccApplication;
--- End code ---
sinc:
No, I need to get the application for the XREF, so I can dig into the XREF database. At least, if I understand Peter's reply correctly.
That code merely returns the application object I already have.
Glenn R:
There is only one 'application'...
Glenn R:
This?
--- Code: ---AcadApplication comAcadApp = acadApp.AcadApplication as AcadApplication;
BlockReference blkRef = null;
// get block reference somehow
...
AcadExternalReference comXref = blkRef.AcadObject as AcadExternalReference;
AcadDatabase xrefDb = comXref.Database;
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version