<?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: Reusing Pro Command - question in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1348953#M10688</link>
    <description>&lt;P&gt;There is a community sample that shows different variations of reusing ProCommands:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Framework/ReusingProCommands" target="_blank"&gt;arcgis-pro-sdk-community-samples/Framework/ReusingProCommands at master · ArcGIS/arcgis-pro-sdk-community-samples (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Nov 2023 21:54:32 GMT</pubDate>
    <dc:creator>Wolf</dc:creator>
    <dc:date>2023-11-13T21:54:32Z</dc:date>
    <item>
      <title>Reusing Pro Command - question</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1346632#M10661</link>
      <description>&lt;P&gt;I need to use the alignMiddle-command in my ArcGIS Pro Add-in, for aligning some elements on the layout. I've seen the article about Reusing Pro Command in the ProGuide. When I add the button for "esri_layouts_alignMiddle" in config.daml I'm able to run the command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to run this command without having to add the button to the ribbon?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 12:11:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1346632#M10661</guid>
      <dc:creator>TorbjørnDalløkken2</dc:creator>
      <dc:date>2023-11-07T12:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing Pro Command - question</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1346683#M10662</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Yes, it is possible. Code below:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;            var pluginWrapper = FrameworkApplication.GetPlugInWrapper(id, true) as System.Windows.Input.ICommand;
            if (pluginWrapper != null)
            {
                if (pluginWrapper.CanExecute(null))
                {
                    pluginWrapper.Execute(null);
                }
            }&lt;/LI-CODE&gt;&lt;P&gt;More info &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic10151.html" target="_self"&gt;here&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 14:27:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1346683#M10662</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-11-07T14:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing Pro Command - question</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1348953#M10688</link>
      <description>&lt;P&gt;There is a community sample that shows different variations of reusing ProCommands:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Framework/ReusingProCommands" target="_blank"&gt;arcgis-pro-sdk-community-samples/Framework/ReusingProCommands at master · ArcGIS/arcgis-pro-sdk-community-samples (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 21:54:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1348953#M10688</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-11-13T21:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing Pro Command - question</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1368915#M10995</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp;, &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp;Does anyone of you know which conditions that needs to be met for the command "esri_layouts_alignMiddle" to be executed?&lt;/P&gt;&lt;P&gt;I've selected to elements from my layout, but CanExecute returns false&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var tmpTextElement = Layout.FindElement(element.Name);
var tmpPunktElement = Layout.FindElement(PunktElement.Name);
Layout.SelectElements(new List&amp;lt;Element&amp;gt; { tmpTextElement, tmpPunktElement });

var pluginWrapperDistributeAlignMiddle = FrameworkApplication.GetPlugInWrapper("esri_layouts_alignMiddle", true) as ICommand;
if (pluginWrapperDistributeAlignMiddle != null)
{
   if (pluginWrapperDistributeAlignMiddle.CanExecute(null))
   {
      pluginWrapperDistributeAlignMiddle.Execute(null);
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 14:49:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1368915#M10995</guid>
      <dc:creator>TorbjørnDalløkken2</dc:creator>
      <dc:date>2024-01-11T14:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing Pro Command - question</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1368949#M10996</link>
      <description>&lt;P&gt;As far as i can tell from looking at ArcGISLayout.daml the following condition has to be met:&lt;/P&gt;&lt;P&gt;id="esri_layouts_selectedElementsNotPartsCondition"&lt;/P&gt;&lt;P&gt;The description for the condition says:&lt;/P&gt;&lt;P&gt;"Elements are selected in the active layout view and FORMAT selection is set to the whole element not a part."&lt;/P&gt;&lt;P&gt;I used your code and it's working fine for me:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override void OnClick()
{
  try
  {
    LayoutView layoutView = LayoutView.Active;
    Layout layout = layoutView.Layout;

    var tmpTextElement = layout.FindElement("TestText 1");
    var tmpPunktElement = layout.FindElement("Point");
    layout.SelectElements(new List&amp;lt;ArcGIS.Desktop.Layouts.Element&amp;gt; { tmpTextElement, tmpPunktElement });
    MessageBox.Show($@"Selected: {layout.GetSelectedElements().Count}");

    var pluginWrapperDistributeAlignMiddle = FrameworkApplication.GetPlugInWrapper("esri_layouts_alignMiddle", true) as ICommand;
    if (pluginWrapperDistributeAlignMiddle != null)
    {
      if (pluginWrapperDistributeAlignMiddle.CanExecute(null))
      {
        pluginWrapperDistributeAlignMiddle.Execute(null);

      }
      else
        MessageBox.Show("Can't execute");
    }
  }
  catch (Exception ex)
  {
    MessageBox.Show(ex.Message);
  }
}&lt;/LI-CODE&gt;&lt;P&gt;These are my two sample elements to be aligned:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1704987494759.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91230i44CB59133CB8CFBB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1704987494759.png" alt="Wolf_0-1704987494759.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After the alignment button completes i see this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_1-1704987554007.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91231i0599C465731FC78B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_1-1704987554007.png" alt="Wolf_1-1704987554007.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 15:39:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1368949#M10996</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2024-01-11T15:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reusing Pro Command - question</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1369465#M10999</link>
      <description>&lt;P&gt;Thank you for testing,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I've now tried adding your code,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp;, and I get a confirmation that 2 elements in the layout is selected. However, the CanExecute(null) returns false and the elements are not aligned. You mentioned the condition-description:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Elements are selected in the active layout view and FORMAT selection is set to the whole element not a part."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Since there are elements selected in the active layout view, then it must be something to do with the FORMAT selection. How do I set this to the whole element and not a part?&lt;/P&gt;&lt;P&gt;Do you have any other suggestions on how to align these, without the use of the align-command?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 09:43:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/reusing-pro-command-question/m-p/1369465#M10999</guid>
      <dc:creator>TorbjørnDalløkken2</dc:creator>
      <dc:date>2024-03-18T09:43:28Z</dc:date>
    </item>
  </channel>
</rss>

