<?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: Implement ICommand with actual ExternalCommandData (not null) in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893369#M30185</link>
    <description>&lt;P&gt;UIApplication.CreateRibbonPanel(String, String)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"This method will create a custom panel &lt;STRONG&gt;&lt;U&gt;appending&lt;/U&gt;&lt;/STRONG&gt; to the specified tab."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If 'wombat' tab exists then don't create it, if it doesn't then create it. This is all related to timing of what add-in comes first (one from pyRevit or your separate one). If pyRevit doesn't check to see if 'wombat' exists before creating it then that is an exception waiting to happen elsewhere with pyRevit (it should try adding with try catch since it doesn't know what already exists). If the name was something more general such as 'Tools' then you can see the issue that pyRevit creators should be made aware of if you are saying it isn't checking.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've never had an issue adding two different panels from two different assemblies to the same tab using standard methods. The examples related to adding to internal tabs likely hold no relevance since the tab you are aiming to add to is not internally created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your actual error is related to a member within a separate assembly not being populated with a value. Likely you would have to invoke the member passing the arguments from your external command, but sounds like not the most straightforward solution.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Nov 2020 23:23:00 GMT</pubDate>
    <dc:creator>RPTHOMAS108</dc:creator>
    <dc:date>2020-11-24T23:23:00Z</dc:date>
    <item>
      <title>Implement ICommand with actual ExternalCommandData (not null)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9891057#M30182</link>
      <description>&lt;P&gt;Hi!&lt;BR /&gt;&lt;BR /&gt;I was following&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/413917"&gt;@jeremytammik&lt;/a&gt;&amp;nbsp;'s post here&amp;nbsp;&lt;A href="https://thebuildingcoder.typepad.com/blog/2013/02/adding-a-button-to-existing-ribbon-panel.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2013/02/adding-a-button-to-existing-ribbon-panel.html&lt;/A&gt;&amp;nbsp;as I want to add a custom panel with custom buttons to one of our existing tabs, but I can't just add it as you would always do, because that existing tab is created through pyRevit (and it can't be created via pyRevit as it needs to access a few things pyRevit cannot access).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I initially thought it wouldn't have worked to add custom C# panels to an existing pyRevit&amp;nbsp; tab, but I tried mostly out of curiosity and I found out it actually is possible! So I followed the steps from the post (link above) and I'm able to create the same button within my pyRevit tab.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I have is that I don't want to open the browser but start an IExternalCommand. So I found this other link&amp;nbsp;&amp;nbsp;&lt;A href="https://thebuildingcoder.typepad.com/blog/2009/12/custom-ribbon-tab.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2009/12/custom-ribbon-tab.html&lt;/A&gt;&amp;nbsp;but then it fails because the Execute(object a) implementation sets&amp;nbsp;ExternalCommandData commandData = null; so then the IExternalCommand fails to retrieve the Application.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;    public class AdskCommandHandler : System.Windows.Input.ICommand
    {
        string AssemblyName
        {
            get;
            set;
        }

        string ClassName
        {
            get;
            set;
        }

        public AdskCommandHandler(
            string assemblyName,
            string className)
        {
            AssemblyName = assemblyName;
            ClassName = className;
        }

        public event EventHandler CanExecuteChanged;

        public bool CanExecute(object a)
        {
            return true;
        }

        public void Execute(object a)
        {
            Assembly assembly = Assembly.LoadFrom(AssemblyName);

            IExternalCommand command = assembly.CreateInstance(ClassName) as IExternalCommand;

            ExternalCommandData commandData = null; // Here is the issue
            string message = string.Empty;
            ElementSet elements = null;

            Result r = command.Execute(commandData,
                    ref message, elements);
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;I've read from the comments Jeremy is saying that we're not supposed to use this workaround because it's not officially supported but then he sends a couple more articles (&lt;A href="https://thebuildingcoder.typepad.com/blog/2009/12/create-a-real-revit-ribbon-tab.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2009/12/create-a-real-revit-ribbon-tab.html&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://thebuildingcoder.typepad.com/blog/2010/01/custom-ribbon-tab-context-switch.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2010/01/custom-ribbon-tab-context-switch.html&lt;/A&gt;) mentioning Guy Robinson managed to fix this. Now I'd really like to see how he did it, but the links in those 2 posts are not working anymore.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any chance anyone has those links functioning??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also curious to see if there are better ways of doing what I'm trying to do?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 06:17:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9891057#M30182</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-24T06:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Implement ICommand with actual ExternalCommandData (not null)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9891608#M30183</link>
      <description>&lt;P&gt;Nice to see all the research you did and resources you examined. Thank you for sharing that path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't understand exactly what you need, but I hope I got the main gist; I also don't understand why you are having any difficulties achieving what you are after. Could you summarise your exact goal very briefly, succinctly?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can't you just add the button using pure .NET, independently of the Revit API, and then use an external event to enter a valid Revit API context when needed? That would be the standard approach...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 10:47:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9891608#M30183</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-11-24T10:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Implement ICommand with actual ExternalCommandData (not null)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893328#M30184</link>
      <description>&lt;P&gt;Thank you for your reply Jeremy!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me try to explain better. Background: where I work we have a custom tab (called Wombat) made of custom tools and that tab is made with pyRevit. This means that I'm not controlling directly the &lt;EM&gt;IExternalApplication&lt;/EM&gt; adding the panels and buttons, but pyRevit is doing it for me. All I need to do is adding folders and files and pyRevit builds the toolbar for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I am working on a new, more complex, tool and for that I needed access to the&amp;nbsp;&lt;EM&gt;IExternalApplication&lt;/EM&gt; and its &lt;EM&gt;OnStartup&lt;/EM&gt; method (I need to do stuff at startup, add a couple of buttons, register a dockable panel, etc.).&lt;/P&gt;&lt;P&gt;At some point we decided that this new tool should live under the Wombat tab (just the location of the button, not the hosting through pyRevit), so I thought that it could have been possible to the add the button in the same way you would add a custom button to an existing tab (i.e. "Architecture", "Structure", etc.), hence I found those links I pasted in the original post&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ATassera_0-1606254197978.png" style="width: 881px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/848319iB097C6E52C0A626D/image-dimensions/881x111?v=v2" width="881" height="111" role="button" title="ATassera_0-1606254197978.png" alt="ATassera_0-1606254197978.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So that's why I thought of using the example here&amp;nbsp;&lt;A href="https://thebuildingcoder.typepad.com/blog/2009/12/custom-ribbon-tab.html" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2009/12/custom-ribbon-tab.html&lt;/A&gt;&amp;nbsp;and implementing&amp;nbsp;&lt;SPAN class="teal"&gt;&lt;EM&gt;AdskCommandHandler&lt;/EM&gt;, but then again, passing&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN class="teal"&gt;ExternalCommandData&lt;/SPAN&gt; commandData = &lt;SPAN class="blue"&gt;null&lt;/SPAN&gt;;&lt;/EM&gt; will fail the &lt;EM&gt;Execute&lt;/EM&gt; method in the&amp;nbsp;&lt;EM&gt;IExternalCommand&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;Adding the buttons in the usual way with&amp;nbsp;&lt;EM&gt;application.CreateRibbonTab("Wombat");&lt;/EM&gt; and then&amp;nbsp;&lt;EM&gt;application.CreateRibbonPanel("Wombat", panelName);&lt;/EM&gt; and then creating the&amp;nbsp;&lt;EM&gt;PushButtonData&lt;/EM&gt; to be added to the panel won't work of course because a tab called "Wombat" already exists&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you say "&lt;SPAN&gt;add the button using pure .NET" do you refer to something like WPF/WinForms buttons and then add an event handler to the .Click event? Can you add a WPF button to a panel?&lt;BR /&gt;That could work too as I just need to get the application from the&amp;nbsp;ExternalCommandData , but I thought this would be even hack-ier than what I was already doing &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 22:50:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893328#M30184</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-24T22:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Implement ICommand with actual ExternalCommandData (not null)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893369#M30185</link>
      <description>&lt;P&gt;UIApplication.CreateRibbonPanel(String, String)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"This method will create a custom panel &lt;STRONG&gt;&lt;U&gt;appending&lt;/U&gt;&lt;/STRONG&gt; to the specified tab."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If 'wombat' tab exists then don't create it, if it doesn't then create it. This is all related to timing of what add-in comes first (one from pyRevit or your separate one). If pyRevit doesn't check to see if 'wombat' exists before creating it then that is an exception waiting to happen elsewhere with pyRevit (it should try adding with try catch since it doesn't know what already exists). If the name was something more general such as 'Tools' then you can see the issue that pyRevit creators should be made aware of if you are saying it isn't checking.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've never had an issue adding two different panels from two different assemblies to the same tab using standard methods. The examples related to adding to internal tabs likely hold no relevance since the tab you are aiming to add to is not internally created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your actual error is related to a member within a separate assembly not being populated with a value. Likely you would have to invoke the member passing the arguments from your external command, but sounds like not the most straightforward solution.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 23:23:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893369#M30185</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2020-11-24T23:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Implement ICommand with actual ExternalCommandData (not null)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893401#M30186</link>
      <description>&lt;P&gt;If you're just trying to add it to a tab that already exists (the Wombat tab), couldn't you just create the panel using the name of the tab without trying to recreate the tab?&lt;/P&gt;&lt;LI-CODE lang="general"&gt;RibbonPanel newPanel = application.CreateRibbonPanel("Wombat", "panelName");&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 24 Nov 2020 23:28:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893401#M30186</guid>
      <dc:creator>AGGilliam</dc:creator>
      <dc:date>2020-11-24T23:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Implement ICommand with actual ExternalCommandData (not null)</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893451#M30187</link>
      <description>&lt;P&gt;Ouch I feel stupid now! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You guys are right! The error wasn't in adding the panel to the existing tab but trying to add create another tab called Wombat with&amp;nbsp;&lt;EM&gt;application.CreateRibbonTab("Wombat);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I just got rid of it nd I'm now simply using&amp;nbsp;&lt;EM&gt;application.CreateRibbonPanel("Wombat, panelName);&lt;/EM&gt; and it works correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Excuse me for the confusion&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 23:55:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9893451#M30187</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-24T23:55:58Z</dc:date>
    </item>
  </channel>
</rss>

