Hi all,
I was wonder if anyone else had had a problem with getting topology parent objects and knew what this issue was. I'm trying to access topology edge parents within an add-in, and currently getting the following error:
java.lang.NoSuchFieldError: m_pFC
at com.esri.arcgis.interop.NativeObjRef.nativeVtblInvokeNative(Native method)
at com.esri.arcgis.interop.NativeObjRef.nativeVtblInvoke(Unknown Source)
at com.esri.arcgis.interop.Dispatch.vtblInvoke(Unknown Source)
at com.esri.arcgis.geodatabase.IEnumTopologyParentProxy.next(Unknown Source)
at... [my line (see below)]
I noticed someone else had the same issue (without an answer) on the old forums in 2005.
Details:
I have a topology layer set up with two feature classes associated with it, and these are turned on. All of these are in a Feature Dataset in a Personal Geodatabase.
All three are in as Layers, each appearing in the ToC, un-nested (I only mention this, because I have seen the same thing nested somehow into the topology layer on other machines but can't replicated it on mine). Both feature class layers contain relatively simple polyline features.
I am using the following code in the add-in. I note that its an add-in, as I've had no luck getting some of the more standard topology code people use working in that environment. I've left out the try-catches and simplified it a bit for clarity.
Any ideas? Everything I've seen in the C#/VB examples suggests it should work. Am I missing something obvious?
Many thanks, Andy.
// Initialise various bits - meat of code in section beyond
mxDoc = (IMxDocument)app.getDocument();
map = mxDoc.getFocusMap();
TopologyLayer topologyLayer = null;
for (int i=0; i < map.getLayerCount(); i++) {
ILayer iLayer = map.getLayer(i); // Works: can get name.
if (iLayer instanceof TopologyLayer) {
topologyLayer = (TopologyLayer) map.getLayer(i); // Works: can get name.
} else {
// Get other layers as IGeoFeatureLayers - works fine.
}
}
// Code to get the parents
ITopology it = topologyLayer.getTopology();
ITopologyGraph iTopologyGraph = (ITopologyGraph) it.getCache();
IEnvelope ie = mxDoc.getActiveView().getExtent(); // Run with whole map visible
iTopologyGraph.build(ie, true); // Can check extents fine
IEnvelope dirtyE = it.validateTopology(ie); // Returns null, which I think it should.
IEnumTopologyEdge iEnumTopologyEdges = iTopologyGraph.getEdges(); // Have also tried with nodes
iEnumTopologyEdges.reset();
ITopologyEdge ite = iEnumTopologyEdges.next(); // Can print the length of ite's associated geometry
IEnumTopologyParent iEnumTopologyParent = (IEnumTopologyParent)ite.getParents();
// Have also tried getting the parents by IGeoFeature layer object selection, and from the topologyGraphy.
// I can select objects in the topology layer by objects in the IGeoFeature layers, and successfully
// print their lengths, so I know they are tied together somehow.
tagesriTopologyParent pp = iEnumTopologyParent.next(); // Error generated here. Also generates error if I try to
// just directly read the attributes without the variable label, just using .next().