<?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: Use IExternalCommandAvailability on PullDownButton in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/use-iexternalcommandavailability-on-pulldownbutton/m-p/12365726#M8735</link>
    <description>&lt;P&gt;As you explain, &lt;STRONG&gt;IExternalCommandAvailability&lt;/STRONG&gt; interface is for &lt;STRONG&gt;PushButton&lt;/STRONG&gt; or objects that execute the interface &lt;STRONG&gt;IExternalCommand&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You probably could create some to enable/disable the &lt;STRONG&gt;PullDownButton&lt;/STRONG&gt; using the Idling event, and I don't think that is worth doing that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why are you not applying the same &lt;STRONG&gt;IExternalCommandAvailability&lt;/STRONG&gt; interface in all the &lt;STRONG&gt;PushButton&lt;/STRONG&gt; inside the PullDownButton?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what happens when all the buttons are not available in &lt;STRONG&gt;PullDownButton&lt;/STRONG&gt; and &lt;STRONG&gt;SplitButton&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Forum - 2023-11-09 10-17-02.gif" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1290751iBAD0B8FF5DAC51D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Forum - 2023-11-09 10-17-02.gif" alt="Forum - 2023-11-09 10-17-02.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All Buttons are the same &lt;STRONG&gt;IExternalCommand&lt;/STRONG&gt; and &lt;STRONG&gt;IExternalCommandAvailability&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Threading.Tasks;

namespace RevitAddin.Forum.Revit.Commands
{
    [Transaction(TransactionMode.Manual)]
    public class CommandSwapAvailable : IExternalCommand, IExternalCommandAvailability
    {
        public static bool IsAvailable { get; set; } = true;
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            IsAvailable = !IsAvailable;
            Task.Run(async () =&amp;gt;
            {
                await Task.Delay(2000);
                IsAvailable = !IsAvailable;
            });
            return Result.Succeeded;
        }

        public bool IsCommandAvailable(UIApplication uiapp, CategorySet categorySet)
        {
            return IsAvailable;
        }
    }
}&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;</description>
    <pubDate>Thu, 09 Nov 2023 13:29:36 GMT</pubDate>
    <dc:creator>ricaun</dc:creator>
    <dc:date>2023-11-09T13:29:36Z</dc:date>
    <item>
      <title>Use IExternalCommandAvailability on PullDownButton</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/use-iexternalcommandavailability-on-pulldownbutton/m-p/12365498#M8734</link>
      <description>&lt;P&gt;There currently is no way to use the IExternalCommandAvailability interface to enable/disable pulldown buttons.&lt;/P&gt;&lt;P&gt;The necessary property AvailabilityClassName only exists for PushButton and Button classes.&lt;/P&gt;&lt;P&gt;This makes some sense as the PullDownButton itself does not implement an external command, so the menu would not know where to look for the class instance for the interface that it must call to check availability.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my menu I have a couple of PullDownButtons that contains command buttons that only are applicable when Revit is in a family document, and also a couple that have command buttons that only apply when Revit is not in a family editor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another way to implement something like the IExternalCommandAvailability interface specifically for PullDownButtons, or will I have to rely on using an Idle event for this?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 11:48:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/use-iexternalcommandavailability-on-pulldownbutton/m-p/12365498#M8734</guid>
      <dc:creator>m.de.vriesTH5VM</dc:creator>
      <dc:date>2023-11-09T11:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use IExternalCommandAvailability on PullDownButton</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/use-iexternalcommandavailability-on-pulldownbutton/m-p/12365726#M8735</link>
      <description>&lt;P&gt;As you explain, &lt;STRONG&gt;IExternalCommandAvailability&lt;/STRONG&gt; interface is for &lt;STRONG&gt;PushButton&lt;/STRONG&gt; or objects that execute the interface &lt;STRONG&gt;IExternalCommand&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You probably could create some to enable/disable the &lt;STRONG&gt;PullDownButton&lt;/STRONG&gt; using the Idling event, and I don't think that is worth doing that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why are you not applying the same &lt;STRONG&gt;IExternalCommandAvailability&lt;/STRONG&gt; interface in all the &lt;STRONG&gt;PushButton&lt;/STRONG&gt; inside the PullDownButton?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what happens when all the buttons are not available in &lt;STRONG&gt;PullDownButton&lt;/STRONG&gt; and &lt;STRONG&gt;SplitButton&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Forum - 2023-11-09 10-17-02.gif" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1290751iBAD0B8FF5DAC51D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Forum - 2023-11-09 10-17-02.gif" alt="Forum - 2023-11-09 10-17-02.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All Buttons are the same &lt;STRONG&gt;IExternalCommand&lt;/STRONG&gt; and &lt;STRONG&gt;IExternalCommandAvailability&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Threading.Tasks;

namespace RevitAddin.Forum.Revit.Commands
{
    [Transaction(TransactionMode.Manual)]
    public class CommandSwapAvailable : IExternalCommand, IExternalCommandAvailability
    {
        public static bool IsAvailable { get; set; } = true;
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            IsAvailable = !IsAvailable;
            Task.Run(async () =&amp;gt;
            {
                await Task.Delay(2000);
                IsAvailable = !IsAvailable;
            });
            return Result.Succeeded;
        }

        public bool IsCommandAvailable(UIApplication uiapp, CategorySet categorySet)
        {
            return IsAvailable;
        }
    }
}&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;</description>
      <pubDate>Thu, 09 Nov 2023 13:29:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/use-iexternalcommandavailability-on-pulldownbutton/m-p/12365726#M8735</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2023-11-09T13:29:36Z</dc:date>
    </item>
  </channel>
</rss>

