protected override void OnClick()
        {
            setupGP.init();
            var param_values = Geoprocessing.MakeValueArray(DataAssistant.Dockpane1View.getXmlFileName());

            Geoprocessing.OpenToolDialog(setupGP.getToolbox("ReplaceData"), param_values);
        }
Esempio n. 2
0
        public ProSuiteQAResponse StartQASync(ProSuiteQARequest parameters)
        {
            var args = PrepareGPToolParameters(parameters, ProSuiteQAToolType.Xml);

            if (args == null)
            {
                return(new ProSuiteQAResponse()
                {
                    Error = ProSuiteQAError.ServiceFailed
                });
            }

            Geoprocessing.OpenToolDialog(_toolpath, args, null, false,
                                         (event_name, o) =>
            {
                if (event_name == "OnEndExecute")
                {
                    var result = o as IGPResult;
                    OnStatusChanged?.Invoke(this, new ProSuiteQAServiceEventArgs(ProSuiteQAServiceState.Finished, result?.Values?.First()));
                }
                else                         // TODO other events than "OnStartExecute" ?
                {
                }
            });
            return(null);
        }
        protected override async void OnClick()
        {
            string timestamp        = DateTime.Now.ToString("yyyyMMddHHmmss");
            string featureClassName = "AOI_Polygon_" + timestamp;

            List <object> arguments = new List <object>
            {
                // store the results in the default geodatabase
                CoreModule.CurrentProject.DefaultGeodatabasePath,
                // name of the feature class
                featureClassName,
                // type of geometry
                "POLYGON",  //POINT,POLYLINE,POLYGON...
                // no template
                "",
                // no z values
                "DISABLED",
                // no m values
                "DISABLED"
            };

            await QueuedTask.Run(() =>
            {
                // spatial reference
                arguments.Add(SpatialReferenceBuilder.CreateSpatialReference(4326)); //3857
            });

            var parameters = Geoprocessing.MakeValueArray(arguments.ToArray());

            Geoprocessing.OpenToolDialog("management.CreateFeatureclass", parameters);

            //await CreateAOILayer();
        }
        protected override void OnClick()
        {
            try
            {
                // Install the toolbox locally and set path to the toolbox
                var toolPath = AutoUpdater.UpdateToolbar() + @"\DownloadMapTemplate";

                //launch script tool from gp pane
                //https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing#open-the-tool-dialog-in-the-geoprocessing-pane

                // Set value array (empty values allow user full control) and launch tool
                var dir           = "";
                var mapReqID      = "";
                var projectName   = "";
                var exorNew       = "";
                var pathtoEx      = "";
                var copyOldData   = "";
                var PAGX_Template = "";
                var toolParams    = Geoprocessing.MakeValueArray(
                    dir, mapReqID, projectName, exorNew, pathtoEx, copyOldData, PAGX_Template);
                Geoprocessing.OpenToolDialog(toolPath, toolParams);
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong " + e);
            }
        }
        protected override void OnClick()
        {
            var parameters = Geoprocessing.MakeValueArray("", "", "POLYGON");

            Geoprocessing.OpenToolDialog("conversion.JSONToFeatures", parameters);

            //await AddGeoJSON();
        }
        protected override void OnClick()
        {
            string input_raster = "";
            string output       = "";
            var    parameters   = Geoprocessing.MakeValueArray(input_raster, output, "POLYGON");

            Geoprocessing.OpenToolDialog("3d.RasterDomain", parameters);
        }
Esempio n. 7
0
        //private string _installPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

        protected override void OnClick()
        {
            try
            {
                //MessageBox.Show(Path.GetTempPath());
                //MessageBox.Show(_installPath);
                string j         = "";
                var    arguments = Geoprocessing.MakeValueArray(j);
                string toolpath  = _pathEmeToolbox + "\\EPA Pro Metadata Toolbox.pyt\\deleteTool";
                Geoprocessing.OpenToolDialog(toolpath, null);

                #region  Exmample for calling python

                //// Inform user that add-in is about to call Python script.
                //ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Click OK to start script, and wait for completion messagebox.", "Info");
                //// Create and format path to Pro
                //var pathProExe = System.IO.Path.GetDirectoryName((new System.Uri(Assembly.GetEntryAssembly().CodeBase)).AbsolutePath);
                //if (pathProExe == null) return;
                //pathProExe = Uri.UnescapeDataString(pathProExe);
                //pathProExe = System.IO.Path.Combine(pathProExe, @"Python\envs\arcgispro-py3");
                //// Create and format path to Python
                //var pathPython = System.IO.Path.GetDirectoryName((new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);
                //if (pathPython == null) return;
                //pathPython = Uri.UnescapeDataString(pathPython);
                //// Create and format process command string.
                //// NOTE:  Path to Python script is below, "C:\temp\RunPython.py", which can be kept or updated based on the location you place it.
                //var myCommand = string.Format(@"/c """"{0}"" ""{1}""""",
                //    System.IO.Path.Combine(pathProExe, "python.exe"),
                //    System.IO.Path.Combine(pathPython, @"C:\EMESolutions\ProEmeTools\clearMd.py"));
                //// Create process start info, with instruction settings
                //var procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", myCommand);
                //procStartInfo.RedirectStandardOutput = true;
                //procStartInfo.RedirectStandardError = true;
                //procStartInfo.UseShellExecute = false;
                //procStartInfo.CreateNoWindow = true;
                //// Create process and start it
                //System.Diagnostics.Process proc = new System.Diagnostics.Process();
                //proc.StartInfo = procStartInfo;
                //proc.Start();
                //// Create and format result string
                //string result = proc.StandardOutput.ReadToEnd();
                //string error = proc.StandardError.ReadToEnd();
                //if (!string.IsNullOrEmpty(error)) result += string.Format("{0} Error: {1}", result, error);
                //// Show result string
                //ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(result, "Info");

                #endregion
            }

            catch (Exception exc)
            {
                // Catch any exception found and display in a message box
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Exception caught while trying to run Python tool: " + exc.Message);
                return;
            }
        }
Esempio n. 8
0
        private async void OpenEucDistance()
        {
            await CommonMethod.OpenMap(ConstDefintion.ConstMap_SpaceAnalyzeMap);

            string   projectDir   = System.IO.Path.GetDirectoryName(Project.Current.Path);
            string   path         = projectDir + "\\" + ConstDefintion.ConstRaster_RaderRangeDsName;
            Envelope env          = CommonMethod.GetRasterExtent(path).Result;
            var      environments = Geoprocessing.MakeEnvironmentArray(extent: env, mask: ConstDefintion.ConstLayer_RaderRangeLayerName);;

            Geoprocessing.OpenToolDialog("sa.EucDistance", null, environments, true, null);
        }
        protected override void OnClick()
        {
            setupGP.init();
            string source = "";
            string target = "";
            string file   = System.IO.Path.Combine(Project.Current.HomeFolderPath, "SourceTarget.xml");

            var param_values = Geoprocessing.MakeValueArray(source, target, file);

            Geoprocessing.OpenToolDialog(setupGP.getToolbox("SourceTargetMapping"), param_values);
        }
Esempio n. 10
0
        private void OpenBufferToolDialog()
        {
            #region open_dialog
            string input_points = @"C:\data\ca_ozone.gdb\ozone_points";
            string output_polys = @"C:\data\ca_ozone.gdb\ozone_buff";
            string buffer_dist  = "2000 Meters";

            var param_values = Geoprocessing.MakeValueArray(input_points, output_polys, buffer_dist);

            Geoprocessing.OpenToolDialog("analysis.Buffer", param_values);
            #endregion
        }
Esempio n. 11
0
 protected override void OnClick()
 {
     #region
     try
     {
         var args = Geoprocessing.MakeValueArray(string.Empty, GeoDataTool.DefaultProject.DefaultGeodatabasePath + "\\" + ConstDefintion.ConstFeatureClass_AisPoint, string.Empty, string.Empty);
         Geoprocessing.OpenToolDialog("management.XYTableToPoint", args, null, false, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     #endregion
 }
Esempio n. 12
0
        protected override void OnClick()
        {
            try
            {
                string toolpath = _pathEmeToolbox + "\\EPA Pro Metadata Toolbox.pyt\\exportISOTool";
                Geoprocessing.OpenToolDialog(toolpath, null);
            }

            catch (Exception exc)
            {
                // Catch any exception found and display in a message box
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Exception caught while trying to run Python tool: " + exc.Message);
                return;
            }
        }
Esempio n. 13
0
        protected override void OnClick()
        {
            LayoutProjectItem layout = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout-Results"));

            if (layout != null)
            {
                var toolPath = @"O:\SHARE\405 - INFORMATION SERVICES\GIS_Layers\Python-Tools\Acoustic-Inspections\AI-Mapbooks.tbx\ResultsExport";

                string[] args = new string[0];
                Geoprocessing.OpenToolDialog(toolPath, args);
            }
            else
            {
                MessageBox.Show("'Layout-Results' not in currect ArcGIS Pro project. This layout and associated map must be in this project for the 'Results Mapbook' tool to function.", "Layout Missing!");
            }
        }
        protected override void OnClick()
        {
            MessageBox.Show("test");
            var inputlayer = (MapView.Active.Map.Layers.First(layer => true) as FeatureLayer);
            //string input_points = @"C:\data\ca_ozone.gdb\ozone_points";
            string output_polys    = System.IO.Path.Combine(System.IO.Path.Combine(ArcGIS.Desktop.Core.Project.Current.HomeFolderPath, "bufferOutPuts.gdb"), "buffer_custom"); // @"C:\data\ca_ozone.gdb\ozone_buff";
            string buffer_dist     = "Miles";
            string line_side       = "FULL";
            string line_end_type   = "ROUND";
            string dissolve_option = "ALL";
            string dissolve_field  = "";
            string method          = "GEODESIC";
            var    param_values    = Geoprocessing.MakeValueArray(inputlayer, output_polys, buffer_dist, line_side, line_end_type, dissolve_option, dissolve_field, method);

            Geoprocessing.OpenToolDialog("analysis.Buffer", param_values);
        }
 public static void OpenCustomGPTool(string systoolboxalias, string systoolalias, IEnumerable <string> args)
 {
     if (AddIn.SystemToolsAvailable)
     {
         //Try Opening tools within system toolbox first
         Geoprocessing.OpenToolDialog(systoolboxalias + "." + systoolalias, args);
     }
     else
     {
         //if exception Open tools from AssemblyCache Instead
         if (systoolboxalias == MTToolboxAlias)
         {
             Geoprocessing.OpenToolDialog(MTToolboxPath + "\\" + systoolalias, args);
         }
     }
 }
Esempio n. 16
0
        protected override void OnClick()
        {
            try
            {
                // Install the toolbox locally and set path to the toolbox
                var toolPath = AutoUpdater.UpdateToolbar() + @"\UploadProject";

                //launch script tool from gp pane
                //https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing#open-the-tool-dialog-in-the-geoprocessing-pane

                // Set value array (empty values allow user full control) and launch tool
                var projectPath   = "";
                var existingOrNew = "";
                var toolParams    = Geoprocessing.MakeValueArray(projectPath, existingOrNew);
                Geoprocessing.OpenToolDialog(toolPath, toolParams);
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong " + e);
            }
        }
 public void StartProcess()
 {
     baseMapLayer = MapView.Active.Map.Layers.First(x => (!(x is FeatureLayer)));
     QueuedTask.Run(() => baseMapLayer.SetVisibility(false));
     Geoprocessing.OpenToolDialog("management.CreateVectorTilePackage", null, null, false, CreateVectorTilePackage_Callback);
 }
 //Option 3 - open the Geoprocessing tool parameter dialog and interactively execute the tool
 internal virtual void ExecuteToolOpenToolDialog(string toolPath, string[] values)
 {
     Geoprocessing.OpenToolDialog(toolPath, values, _env.ToArray(), false, null);
 }
Esempio n. 19
0
        public async void CodeExamples()
        {
            #region How to execute a Model tool
            // get the model tool's parameter syntax from the model's help
            string input_roads      = @"C:\data\Input.gdb\PlanA_Roads";
            string buff_dist_field  = "Distance"; // use values from a field
            string input_vegetation = @"C:\data\Input.gdb\vegtype";
            string output_data      = @"C:\data\Output.gdb\ClippedFC2";

            // the model name is ExtractVegetation
            string tool_path = @"C:\data\MB\Models.tbx\ExtractVegetation";

            var args = Geoprocessing.MakeValueArray(input_roads, buff_dist_field, input_vegetation, output_data);

            var result = Geoprocessing.ExecuteToolAsync(tool_path, args);
            #endregion


            #region Set Geoprocessing extent environment

            var parameters = Geoprocessing.MakeValueArray(@"C:\data\data.gdb\HighwaysUTM11", @"C:\data\data.gdb\Highways_extent");
            var ext        = Geoprocessing.MakeEnvironmentArray(extent: "460532 3773964 525111 3827494");
            var gp_result  = await Geoprocessing.ExecuteToolAsync("management.CopyFeatures", parameters, ext);

            #endregion


            #region Open a script tool dialog in Geoprocessing pane
            string input_data = @"C:\data\data.gdb\Population";
            string out_pdf    = @"C:\temp\Reports.pdf";
            string field_name = "INCOME";
            // use defaults for other parameters - no need to pass any value
            var arguments = Geoprocessing.MakeValueArray(input_data, out_pdf, field_name);

            string toolpath = @"C:\data\WorkflowTools.tbx\MakeHistogram";

            Geoprocessing.OpenToolDialog(toolpath, args);
            #endregion


            #region Get Geoprocessing project items
            var gpItems = CoreModule.CurrentProject.Items.OfType <GeoprocessingProjectItem>();

            // go through all the available toolboxes
            foreach (var gpItem in gpItems)
            {
                var itemsInsideToolBox = gpItem.GetItems();

                // then for each toolbox list the tools inside
                foreach (var toolItem in itemsInsideToolBox)
                {
                    string newTool = String.Join(";", new string[] { toolItem.Path, toolItem.Name });
                    // do something with the newTool
                    // for example, add to a list to track or use them later
                }
            }
            #endregion

            #region Stop a featureclass created with GP from automatically adding to the map
            // However, settings in Pro App's Geoprocessing Options will override option set in code
            // for example, in Pro App's Options > Geoprocessing dialog, if you check 'Add output datasets to an open map'
            // then the output WILL BE added to history overriding settings in code
            var GPresult = Geoprocessing.ExecuteToolAsync(tool_path, args, null, null, null, GPExecuteToolFlags.None);
            #endregion

            #region GPExecuteToolFlags.AddToHistory will add the execution messages to Hisotry
            // However, settings in Pro App's Geoprocessing Options will override option set in code
            // for example, if in Options > Geoprocessing dialog, if you uncheck 'Write geoprocessing operations to Geoprocessing History'
            // then the output will not be added to history.
            var result2 = Geoprocessing.ExecuteToolAsync(tool_path, args, null, null, null, GPExecuteToolFlags.AddToHistory);
            #endregion
        }
        private async void GPToolRun()
        {
            try
            {
                //string toolboxPath = @"D:\RnD_Data\EsriTraining\PythonGP\Scripts\CreateFCAndFields.pyt\CreateFeatureClassAndFields";
                string toolboxPath = @"D:\RnD_Data\EsriTraining\PythonGP\ScriptTool\CreateFCAndFields.tbx\CreateFCAndFields";
                string gdbPath     = @"D:\RnD_Data\EsriTraining\PythonGP\Data\SanJuan.gdb";

                string fcName       = "TempFeature_" + DateTime.Now.ToString("yyyyMMddHHmmssf");
                string geometryType = "POINT";
                string hasZValue    = "DISABLED";
                //SpatialReference outSR = SpatialReferenceBuilder.CreateSpatialReference(4326);
                int outSR = 4326;
                List <FieldInfo> fieldInfoList = new List <FieldInfo>();
                fieldInfoList.Add(new FieldInfo()
                {
                    aliasName = "Home",
                    name      = "Home",
                    fieldType = (int)FieldType.String,
                    length    = 255
                });
                fieldInfoList.Add(new FieldInfo()
                {
                    aliasName = "Created By",
                    name      = "Created By",
                    fieldType = (int)FieldType.String,
                    length    = 255
                });
                fieldInfoList.Add(new FieldInfo()
                {
                    aliasName = "Age",
                    name      = "Age",
                    fieldType = (int)FieldType.Integer
                });
                fieldInfoList.Add(new FieldInfo()
                {
                    aliasName = "Updated Date",
                    name      = "Updated Date",
                    fieldType = (int)FieldType.Date
                });
                bool   result           = false;
                string message          = "";
                string strFieldInfoList = "[['school_name', 'TEXT', 'Name', 255, 'Hello world', '']," +
                                          "['street_number', 'LONG', 'Street Number', None, 35, 'StreetNumDomain']," +
                                          "['year_start', 'DATE', 'Year Start', None, '2017-08-09 16:05:07', '']]";
                List <List <string> > FieldInfoList = new List <List <string> >()
                {
                    new List <string>()
                    {
                        "school_name", "TEXT", "Name", "255", "Hello world", ""
                    },
                    new List <string>()
                    {
                        "year_start", "DATE", "Year Start", "None", "2017-08-09 16:05:07", ""
                    }
                };

                //Correct way of import
                List <string> strFieldList = new List <string>()
                {
                    "'school_name' 'TEXT' 'Name' 255 'Hello world' ''",
                    "'year_start' 'DATE' 'Year Start' None '2017-08-09 16:05:07' ''"
                };

                var arguments = Geoprocessing.MakeValueArray(gdbPath, fcName, geometryType, hasZValue, outSR, strFieldList, result, message);
                Geoprocessing.OpenToolDialog(toolboxPath, arguments);
                //var gpResult = Geoprocessing.ExecuteToolAsync(toolboxPath, arguments);
                //gpResult.Wait();
                //IGPResult ProcessingResult = gpResult.Result;
                //if (ProcessingResult.IsFailed)
                //{
                //    string errorMessage = "";
                //    foreach (IGPMessage gpMessage in ProcessingResult.Messages)
                //    {
                //        errorMessage += $"{{Error Code: {gpMessage.ErrorCode}, Text :  {gpMessage.Text} }}";
                //    }
                //    MessageBox.Show($"Geoprocessing fail {errorMessage}");
                //}
                //else
                //{
                //    MessageBox.Show("Process  success");

                //}
                //using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("dkfs"))))

                //using (FeatureClassDefinition featureClass = fileGeodatabase.GetDefinition<FeatureClassDefinition>("dkfs"))

                //{
                //    this.FieldListToAdd = featureClass.GetFields();
                //}
            }
            catch (Exception exce)
            {
                MessageBox.Show($"Exception occured {exce.Message}{Environment.NewLine}{exce.StackTrace}");
            }
        }