Select to view content in your preferred language

Update environment settings

935
7
12-06-2023 06:08 AM
pocalipse
Regular Contributor

Hi

How do I update/set an environment setting in ArcGIS PRO using C# ?

Best regards,
Jens Søe

0 Kudos
7 Replies
pocalipse
Regular Contributor

Hi @CharlesMacleod 

It isn't he system environments variables I'm seeking - it is the list of environment settings in ArcGIS PRO found under the analysis TAB:

pocalipse_0-1701950043313.png

It is pretty easy in Python but how do I set these using .net ?

 

0 Kudos
CharlesMacleod
Esri Regular Contributor

Pls use: 

Geoprocessing.MakeEnvironmentArray

https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9386.html

There are examples on that page

0 Kudos
pocalipse
Regular Contributor

Hi

That is when you want to use the setting, but how do I change a setting and save it in the my project?

0 Kudos
CharlesMacleod
Esri Regular Contributor

Gotcha. it's not supported. i'll take this as a new requirement for GP

0 Kudos
DrewFlater
Esri Regular Contributor

@pocalipse ,
@CharlesMacleod is correct that there is not a way through the Pro .NET API to change or set Geoprocessing Environments for your project. @pocalipse can you explain what your intention is for having an Add-in or Extension or other SDK element setting the project Geoprocessing environments? @CharlesMacleod mentioned the MakeEnvironmentArray function, which you can use to set all of desired environment settings, then reuse that environment array for any tools you run using ExecuteToolAsync, so the effect can be quite similar to setting the environments to the project. For example (pseudo code)

 

var env = Geoprocessing.MakeEnvironmentArray(outputCoordinateSystem: a_spatial_reference, extent: an_extent_window);

Geoprocessing.ExecuteToolAsync(tool1, params1, env);
Geoprocessing.ExecuteToolAsync(tool2, params2, env);
Geoprocessing.ExecuteToolAsync(tool3, params3, env);

 


Maybe you have a different reason for setting the project's geoprocessing environments beyond their use for environments used in the tools you execute in an Add-in. Please let us know any details for this request. 

Since this is the SDK Questions forum, and the question is answered that we do not have a function to set project environments in .NET, if you would like to submit an idea like "Update project's geoprocessing environments using .NET" to the ArcGIS Pro Ideas site, we can get comments from the user community and use that to try to prioritize this new development work. https://community.esri.com/t5/arcgis-pro-ideas/idb-p/arcgis-pro-ideas

0 Kudos
pocalipse
Regular Contributor

Hi

I'm currently building an add-in with a button, that create/build a project template. It is quite more advanced than what is possible with the buildin tools for project templates. 

Some of the things I like to do is setting some of these global settings in hte environment settings so users don't have to do it themself and I throught that this would be the easy part of my button 🙂

0 Kudos