private IFeatureClass RunProcessGetFeatureClass(IGPProcess inProcess, ITrackCancel inCancel, string ignoreMessage) { IFeatureClass fc = null; IQueryFilter qf = null; IGeoProcessorResult result = null; IGPUtilities util = null; try { string toolbox = inProcess.ToolboxName; mLog.Debug("inside run process"); mLog.Debug("the process I want to run is " + inProcess.ToolName); mLog.Debug("the tool box is " + toolbox); myProcessor.OverwriteOutput = true; result = (IGeoProcessorResult)myProcessor.Execute(inProcess, null); ReturnMessages(myProcessor); //if result is null then there are no viable areas if (result != null) { util = new GPUtilitiesClass(); util.DecodeFeatureLayer(result.GetOutput(0), out fc, out qf); ReturnMessages(myProcessor, ignoreMessage); } } catch (Exception ex) { eLog.Debug(ex); ReturnMessages(myProcessor); } return(fc); }
public bool RunTool(string toolName, IVariantArray parameters, ITrackCancel TC, bool showResultDialog) { GeoProcessor gp = new GeoProcessor(); IGeoProcessorResult result = null; // Execute the tool try { result = (IGeoProcessorResult)gp.Execute(toolName, parameters, TC); string re = result.GetOutput(0).GetAsText(); if (showResultDialog) { ReturnMessages(result, ""); } if (result.MaxSeverity == 2) //error { return(false); } else { return(true); } } catch (COMException err) { MessageBox.Show(err.Message + " in RunTool"); ReturnMessages(result, ""); } catch (Exception err) { MessageBox.Show(err.Message + " in RunTool"); ReturnMessages(result, ""); } return(false); }
private void GetFeatureClassFromFileName(string inFileName, out IFeatureClass fc, out IQueryFilter qf) { fc = null; qf = null; try { MakeFeatureLayer makefeaturelayer = new MakeFeatureLayer(); makefeaturelayer.in_features = inFileName; makefeaturelayer.out_layer = "tempLayer"; IGeoProcessorResult result = (IGeoProcessorResult)myProcessor.Execute(makefeaturelayer, null); IGPUtilities util = new GPUtilitiesClass(); util.DecodeFeatureLayer(result.GetOutput(0), out fc, out qf); } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
public static string ConvertMXDToMSD(string mxdfile, string convertMXDtoMSDtoolboxPath) { if (!File.Exists(convertMXDtoMSDtoolboxPath)) { MessageBox.Show(string.Format("GP Toolbox {0} to convert mxd to msd is not found", convertMXDtoMSDtoolboxPath), "Convert MXD to MSD", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } Geoprocessor gp = new Geoprocessor() { OverwriteOutput = true }; gp.AddToolbox(convertMXDtoMSDtoolboxPath); IVariantArray gpparams = new VarArrayClass(); gpparams.Add(mxdfile); IGeoProcessorResult gpresult = null; try { gpresult = gp.Execute(Properties.Settings.Default.toolname, gpparams, null) as IGeoProcessorResult; } catch (Exception) { object sev = 2; System.Windows.MessageBox.Show(gp.GetMessages(ref sev)); return(null); } string msdfile = ((IGPString)gpresult.GetOutput(0)).Value; //MessageBox.Show(msdfile); gp = null; gpresult = null; return(msdfile); }
public string getOutput(IGeoProcessorResult result, int index) { return result.GetOutput(index).GetAsText(); }
public string getOutput(IGeoProcessorResult result, int index) { return(result.GetOutput(index).GetAsText()); }