<?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: Transfer data to ExternalEvent in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/transfer-data-to-externalevent/m-p/6700142#M61852</link>
    <description>&lt;P&gt;Your&amp;nbsp;&lt;SPAN&gt;StaticSelection class &amp;nbsp;does not need to be static, only its members. static classes are usually for extensions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Those members in your&amp;nbsp;StaticSelection should be on your&amp;nbsp;MyEvent, or at least you should be able to&amp;nbsp;pass them. In the example code next I used a property, but you can use a method instead.&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;&lt;PRE&gt;    public class MyUI
    {
        ExternalEvent m_ExEvent;
        private MyEvent myEvent;
        private List&amp;lt;ElementId&amp;gt; selectedIds;

        public void OnowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            myEvent.Ids = selectedIds&lt;BR /&gt;
            m_ExEvent.Raise();
        }
    }

    public class MyEvent : IExternalEventHandler
    {
        public List&amp;lt;ElementId&amp;gt; Ids { get; set; }

        void IExternalEventHandler.Execute(UIApplication app)
        {
            //check for ids == null ?

            app.ActiveUIDocument.Selection.SetElementIds(ids);
        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, you can remove the LinkedIn link from your signature and get ready to very soon&amp;nbsp;remove facebook one &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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2016 15:33:33 GMT</pubDate>
    <dc:creator>GonçaloFeio1321</dc:creator>
    <dc:date>2016-11-21T15:33:33Z</dc:date>
    <item>
      <title>Transfer data to ExternalEvent</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/transfer-data-to-externalevent/m-p/6699994#M61851</link>
      <description>&lt;P&gt;Hi everyone.&lt;/P&gt;
&lt;P&gt;I learn an ExternalEvent mechanism &lt;A href="http://help.autodesk.com/view/RVT/2017/ENU/?guid=GUID-0A0D656E-5C44-49E8-A891-6C29F88E35C0" target="_self"&gt;by this page&lt;/A&gt;. Everything ok, event is work succesfully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I want to transfer data in my event. For example, I want to crop 3dview by element after click row in table&amp;nbsp;on form. I want to transfer ElementId in my event, but Raise() method have no arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I solved a problem with public static class: save data to static class in form, and get data from static class in event.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it is not beautiful, I&amp;nbsp;think it must be another way. Please help.&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;
&lt;PRE&gt;public static class StaticSelection
{
  public static List&amp;lt;ElementId&amp;gt; Ids;
  public static string DocTitle = "";
  public static double CropSize = 10;
}
private void dataGrid_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
...
  StaticSelection.Ids = selectedIds;
  StaticSelection.DocTitle = "Document.rvt";
  StaticSelection.CropSize = trackBarCropZise.Value;
  m_ExEvent.Raise();
}

public class MyEvent : IExternalEventHandler
{
  void IExternalEventHandler.Execute(UIApplication app)
  {
    Document doc = app.ActiveUIDocument.Document;
    List&amp;lt;ElementId&amp;gt; ids = StaticSelection.Ids;
    app.ActiveUIDocument.Selection.SetElementIds(StaticSelection.Ids);
  }
...
}&lt;/PRE&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>Mon, 21 Nov 2016 14:43:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/transfer-data-to-externalevent/m-p/6699994#M61851</guid>
      <dc:creator>Extraneous</dc:creator>
      <dc:date>2016-11-21T14:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer data to ExternalEvent</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/transfer-data-to-externalevent/m-p/6700142#M61852</link>
      <description>&lt;P&gt;Your&amp;nbsp;&lt;SPAN&gt;StaticSelection class &amp;nbsp;does not need to be static, only its members. static classes are usually for extensions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Those members in your&amp;nbsp;StaticSelection should be on your&amp;nbsp;MyEvent, or at least you should be able to&amp;nbsp;pass them. In the example code next I used a property, but you can use a method instead.&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;&lt;PRE&gt;    public class MyUI
    {
        ExternalEvent m_ExEvent;
        private MyEvent myEvent;
        private List&amp;lt;ElementId&amp;gt; selectedIds;

        public void OnowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            myEvent.Ids = selectedIds&lt;BR /&gt;
            m_ExEvent.Raise();
        }
    }

    public class MyEvent : IExternalEventHandler
    {
        public List&amp;lt;ElementId&amp;gt; Ids { get; set; }

        void IExternalEventHandler.Execute(UIApplication app)
        {
            //check for ids == null ?

            app.ActiveUIDocument.Selection.SetElementIds(ids);
        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, you can remove the LinkedIn link from your signature and get ready to very soon&amp;nbsp;remove facebook one &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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 15:33:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/transfer-data-to-externalevent/m-p/6700142#M61852</guid>
      <dc:creator>GonçaloFeio1321</dc:creator>
      <dc:date>2016-11-21T15:33:33Z</dc:date>
    </item>
  </channel>
</rss>

