1

I am trying to use this tool which can be found in the ArcToolBox under data management, geometric network

Tool

I need to access this tool using ArcObjects because I have loaded features into their respective feature classes, and I would like to run an exauhstive check on their geometric network status using the extent.

I came across IGeometricNetworkConnectivity2, and I can use it on each feature class separately, but it does not allow me to do an exhaustive search or use an extent for that matter, it will run on the entire . Here a sample of where I am at now

var ftrClass =LoadFeatureClass(shapeFileObject)
var netWorkGeo = ftrClass as INetworkClass;
var nWCheck=(IGeometricNetworkConnectivity2)netWorkGeo.GeometricNetwork
string logger= string.Empty;
ISet set = new Set();
bool consistincy;
nWCheck.CheckAndRepairConnectivity(true, logger, out set,out consistincy,repairConnectivityProg);

I tried using the IGeoProcessor Interface to run the tool, but I am getting an exception eventhough I am passing correct parameters according to the ArcToolBox Help provided. The exception is raised on Execute.

   try {
            var array = new VarArrayClass();
            var gp = new GeoProcessorClass();
            gp.AddToolbox(@"c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Toolboxes\Data Management Tools.tbx");
            array.Add("ElectCoilNet");
            array.Add(@"c:\OutLog.txt");
            array.Add("VERIFY_ONLY");

            var result = gp.Execute("VerifyAndRepairGeometricNetworkConnectivity_management", array, null);

        } catch (Exception ex) { Logger.LogException(ex);}

1 Answer 1

3

If an interface is not exposing what you want why not simply call the existing tool?

You can call existing geo-processing tools in ArcObjects using the IGeoProcessor interface. So you would create an array populate it with the information you would have entered as if you were using the tool and then call it. Have a look at the code here, this will help you understand how to call tools and interact with their result objects.

4
  • Great, but I am running into problems using this was. I keep getting an exception "Error HRESULT E_FAIL has been returned from a call to a COM component." On Execute which I think has something to do with the Parameters being passed. Check out what I did and let me now if you have any comments
    – ZZZ
    Commented Dec 26, 2017 at 10:25
  • @ZZZ looking at your code it seems you have followed the correct syntax. The only thing I can offer is not to write your log file to root drive space. I know windows can have security settings that stop that, try writing it to something like c:\temp?
    – Hornbydd
    Commented Dec 26, 2017 at 20:47
  • Thank you for your help, I tried changing the location of the out log with no success.
    – ZZZ
    Commented Dec 27, 2017 at 8:16
  • 1
    I got it to work. It turns out that I had the path for the geometric network class all wrong. Thanks a lot
    – ZZZ
    Commented Dec 27, 2017 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.