我在ArcMap 10.2.2中创建了一个自定义模型工具。如果我们在ArcMap上运行此工具,我们注意到该工具运行正常。就好像我们在Geo处理工具下的Arc Objects中调用相同的那样,它会抛出一个错误,如下所示
错误消息
IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(@"C:\temp\IDW\New\ShapeFiles", 0);
IFeatureClass pSourceFC = featureWorkspace.OpenFeatureClass("BA31_3429_2016");
Geoprocessor GP = new Geoprocessor();
GP.SetEnvironmentValue("Extent", "1745440.000 5922240.000 1745920.000 5921520.000");
GP.AddToolbox(@"D:\temp\My_Tools.tbx");
IVariantArray parameters = new VarArrayClass();
parameters.Add(pSourceFC);
parameters.Add("Shape.Z");
parameters.Add(txtoutput.Text + "\\" + pSourceFC.AliasName + ".asc");
parameters.Add(1);
GP.Execute("IDWtoASCII", parameters, null);
模型构建器