<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change options by SDK in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1244138#M9212</link>
    <description>&lt;P&gt;Thanks Gintautas, This looks like a bug in the Beta. We will fix it for final.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Dec 2022 22:49:57 GMT</pubDate>
    <dc:creator>CharlesMacleod</dc:creator>
    <dc:date>2022-12-28T22:49:57Z</dc:date>
    <item>
      <title>Change options by SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243727#M9206</link>
      <description>&lt;P&gt;I would like to change&amp;nbsp; for many people automatically the option to use undo in GP tools by default.&lt;/P&gt;&lt;P&gt;You can see the option I would like to change in the attached screen shot.&lt;/P&gt;&lt;P&gt;Pro SDK have this:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic73588.html" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic73588.html&lt;/A&gt;&amp;nbsp; but it does not have this option.&lt;/P&gt;&lt;P&gt;I could not find anything in registry or user profile that store this option but since Pro "remember" the new value it must be written somewhere.&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 07:13:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243727#M9206</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-12-27T07:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Change options by SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243890#M9208</link>
      <description>&lt;P&gt;Mody, we can expose this property to allow for api change at &lt;STRIKE&gt;3.2 &lt;/STRIKE&gt;3.1&lt;/P&gt;&lt;P&gt;In the meanwhile, u can use something like this to change it programmatically if u must but I dont really recommend it. There are caveats when changing the User.Config programmatically like this:&lt;/P&gt;&lt;P&gt;1. The application can cache properties and their values and I dont know if this is the case with EnableUndo.&lt;/P&gt;&lt;P&gt;2. This code saves the User.Config on disk and this save is not synchronized with the Options dialog or other application code that may be saving the User.Config (which cld lead to a conflict if both try to save at the same time)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class ToggleGP_EnableUndo : Button {

 private static readonly string GP_EnableUndo = "EnableUndo";

 protected override void OnClick() {
   var enable_undo = GetGPEnableUndoSetting();
   SetGPEnableUndoSetting(!enable_undo);
 }

 private bool GetGPEnableUndoSetting() {
   var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(
   ConfigurationUserLevel.PerUserRoamingAndLocal);
   var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup;
   var gp_Section = group.Sections["ArcGIS.Desktop.Internal.GeoProcessing.Properties.Settings"] as ClientSettingsSection;
   var enableUndoSetting = gp_Section?.Settings.Get(GP_EnableUndo);
   var rawValue = enableUndoSetting?.Value?.ValueXml?.InnerText ?? "False";
   return Boolean.Parse(rawValue);

 }
 private void SetGPEnableUndoSetting(bool enable_undo) {
   var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
   var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup;
   var gp_Section = group.Sections["ArcGIS.Desktop.Internal.GeoProcessing.Properties.Settings"] as ClientSettingsSection;

   var enableUndoSetting = gp_Section.Settings.Get(GP_EnableUndo);
   //null check...
   if (enableUndoSetting == null) {
     //create a new value
     var element = new SettingElement(GP_EnableUndo, SettingsSerializeAs.String);
     var xElement = new XElement(XName.Get("value"));
     XmlDocument doc = new XmlDocument();
     XmlElement valueXml = doc.ReadNode(xElement.CreateReader()) as XmlElement;
     valueXml.InnerText = enable_undo.ToString();
     element.Value.ValueXml = valueXml;
     gp_Section.Settings.Add(element);
   }
   else  {
     //change the value
     XmlDocument doc = new XmlDocument();
     var sr = new StringReader(enableUndoSetting.Value.ValueXml.OuterXml);
     XmlElement valueXml = doc.ReadNode(XmlReader.Create(sr)) as XmlElement;
     valueXml.InnerText = enable_undo.ToString();
     enableUndoSetting.Value.ValueXml = valueXml;
   }
   config.Save();
 }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 22:48:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243890#M9208</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-12-28T22:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: Change options by SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243949#M9209</link>
      <description>&lt;P&gt;Hi Charly&lt;/P&gt;&lt;P&gt;Thanks and happy new year.&lt;/P&gt;&lt;P&gt;As you said - this is a big over kill.&lt;/P&gt;&lt;P&gt;I was hopping somebody will explain where it saved in default and I can write some external code to go and change it from outside Pro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 06:26:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243949#M9209</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-12-28T06:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Change options by SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243950#M9210</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It is exposed on ArcGIS Pro 3.1 Beta but it does not work as expected.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;            QueuedTask.Run(() =&amp;gt;
            {
                ApplicationOptions.GeoprocessingOptions.SetEnableUndoOn(true);
            });&lt;/LI-CODE&gt;&lt;P&gt;I have tried to read new value of property and it still has old value.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 08:27:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1243950#M9210</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-12-28T08:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Change options by SDK</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1244138#M9212</link>
      <description>&lt;P&gt;Thanks Gintautas, This looks like a bug in the Beta. We will fix it for final.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 22:49:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-options-by-sdk/m-p/1244138#M9212</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-12-28T22:49:57Z</dc:date>
    </item>
  </channel>
</rss>

