<?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: Run IExternalCommand by pressing custom RibbonButton in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/run-iexternalcommand-by-pressing-custom-ribbonbutton/m-p/10038129#M28704</link>
    <description>&lt;P&gt;Welcome to the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please simply work through the standard getting started material and all your questions will be answered:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#2" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jan 2021 10:30:34 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2021-01-28T10:30:34Z</dc:date>
    <item>
      <title>Run IExternalCommand by pressing custom RibbonButton</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/run-iexternalcommand-by-pressing-custom-ribbonbutton/m-p/10037883#M28703</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I apologize in advance for the question, which had already been raised, but I can't solve my problem.&lt;BR /&gt;I want make custom tab with button to run my external command:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public class CopySheets : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
         UIApplication uiapp = commandData.Application;
         UIDocument uidoc = uiapp.ActiveUIDocument;
         Document doc = uidoc.Document;

         using (CopySheetsForm csf = new CopySheetsForm(doc, uiapp))
         {
              csf.ShowDialog();
         }

         return Result.Succeeded;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I was following this post&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;to write my IExternalApplication:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;class App : IExternalApplication
{
    public Result OnStartup(UIControlledApplication a)
    {
        adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon;
        RibbonControl ribbonControl = adWin.ComponentManager.Ribbon;

        RibbonTab tab = new RibbonTab();
        tab.Title = "MyPlugins";
        tab.Id = "MYPLUGINS_TAB_ID";
        ribbon.Tabs.Add(tab);

        Autodesk.Windows.RibbonPanelSource srcPanel = new Autodesk.Windows.RibbonPanelSource();
        srcPanel.Title = "Functions";
        Autodesk.Windows.RibbonPanel panel = new Autodesk.Windows.RibbonPanel();
        panel.Source = srcPanel;
        tab.Panels.Add(panel);

        adWin.RibbonButton button = new adWin.RibbonButton();
        button.CommandHandler = new AdskCommandHandler("ScriptsV01.dll", "ScriptsV01.CopySheets");
        adWin.ComponentManager.UIElementActivated += new EventHandler&amp;lt;adWin.UIElementActivatedEventArgs&amp;gt;(ComponentManager_UIElementActivated);
        panel.Source.Items.Add(button);

        return Result.Succeeded;

    }

    public Result OnShutdown(UIControlledApplication a)
    {
         return Result.Succeeded;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I created class, as in the above example, to be able to run my command:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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)
    {
        System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(
                AssemblyName);

        IExternalCommand command
              = assembly.CreateInstance(
                ClassName) as IExternalCommand;

        ExternalCommandData commandData = null;
        string message = string.Empty;
        ElementSet elements = null;

        command.Execute(commandData,
                ref message, elements);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The promblem is, when I press button, it returns an error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="123.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/873235i7D6E7834B00D31F0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="123.png" alt="123.png" /&gt;&lt;/span&gt;&lt;BR /&gt;I saw a similar problem here:&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9891057#M51380" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/implement-icommand-with-actual-externalcommanddata-not-null/m-p/9891057#M51380&lt;/A&gt;&lt;BR /&gt;but the solution didn't help.&lt;BR /&gt;So how can I run my command by pressing custom button? Any help you could provide would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 08:43:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/run-iexternalcommand-by-pressing-custom-ribbonbutton/m-p/10037883#M28703</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-28T08:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Run IExternalCommand by pressing custom RibbonButton</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/run-iexternalcommand-by-pressing-custom-ribbonbutton/m-p/10038129#M28704</link>
      <description>&lt;P&gt;Welcome to the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please simply work through the standard getting started material and all your questions will be answered:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#2" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 10:30:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/run-iexternalcommand-by-pressing-custom-ribbonbutton/m-p/10038129#M28704</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2021-01-28T10:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: Run IExternalCommand by pressing custom RibbonButton</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/run-iexternalcommand-by-pressing-custom-ribbonbutton/m-p/10042744#M28705</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Download the Revit SDK, it has loads of sample also for making you're own RibbonTab with command buttons.&lt;/P&gt;&lt;P&gt;See the sample "Ribbon".&amp;nbsp;&lt;A title="About the Revit SDK" href="https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/Revit-Customize/files/GUID-D7E8694D-7DB3-41CA-A0F3-AF64DC2DA015-htm.html" target="_blank" rel="noopener"&gt;About the Revit SDK&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 19:20:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/run-iexternalcommand-by-pressing-custom-ribbonbutton/m-p/10042744#M28705</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2021-01-29T19:20:51Z</dc:date>
    </item>
  </channel>
</rss>

