<?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 filter elements after selection in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6825826#M60789</link>
    <description>&lt;P&gt;hello again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This&amp;nbsp; is my first post in this forum&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;well,my problem is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How I can filter elemet after selection?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;IList&amp;lt;Element&amp;gt; pickedElements = uidoc.Selection.PickElementsByRectangle("Made rectangle");

 if (pickedElements.Count &amp;gt; 0)
                {

                    Lista_idElement = new List&amp;lt;string&amp;gt;();
          
                    foreach (Element element in pickedElements)

                    {
                        if (element is Wall)
                        {

                            { TaskDialog.Show("Revit", " wall"); }



                            // get ElementType
                            ElementId id = element.GetTypeId();
                            // get Element_id (idElement variable definida al principio)
                            idElement = element.Id.ToString();
                            // get type element ( type variable definida al principio)
                            tipo_elemento = doc.GetElement(element.GetTypeId()) as ElementType;




                            Lista_idElement.Add(idElement);
                            Lista_tipo_elemento.Add(tipo_elemento.ToString());

                            // get the builtin parameter

                            Parameter param_codigo = tipo_elemento.get_Parameter(BuiltInParameter.KEYNOTE_PARAM);
                            Parameter param_C1 = tipo_elemento.LookupParameter("C1");

                            paramametro_C1 = param_C1.AsString();

                           
                            parametro_codigo = param_codigo.AsString();


                            Lista_codigo.Add(parametro_codigo);


                            Lista_C1.Add(param_C1.ToString());

                        } 

                        else
                        { TaskDialog.Show("Revit", "No is wall"); }

                        }&lt;/PRE&gt;&lt;P&gt;With this code when i do the rectangle selection add to list "Lista_tipo_elemento" all the element ,not only the wall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i look for some like....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;foreach (Element element in pickedElements)

                    {
                        if (element is Wall)
                        {......make list of wall........}

if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Windows)
{..........make list of windows........}&lt;/PRE&gt;&lt;P&gt;thanks¡¡¡&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 22:53:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-01-23T22:53:25Z</dc:date>
    <item>
      <title>filter elements after selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6825826#M60789</link>
      <description>&lt;P&gt;hello again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This&amp;nbsp; is my first post in this forum&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;well,my problem is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How I can filter elemet after selection?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;IList&amp;lt;Element&amp;gt; pickedElements = uidoc.Selection.PickElementsByRectangle("Made rectangle");

 if (pickedElements.Count &amp;gt; 0)
                {

                    Lista_idElement = new List&amp;lt;string&amp;gt;();
          
                    foreach (Element element in pickedElements)

                    {
                        if (element is Wall)
                        {

                            { TaskDialog.Show("Revit", " wall"); }



                            // get ElementType
                            ElementId id = element.GetTypeId();
                            // get Element_id (idElement variable definida al principio)
                            idElement = element.Id.ToString();
                            // get type element ( type variable definida al principio)
                            tipo_elemento = doc.GetElement(element.GetTypeId()) as ElementType;




                            Lista_idElement.Add(idElement);
                            Lista_tipo_elemento.Add(tipo_elemento.ToString());

                            // get the builtin parameter

                            Parameter param_codigo = tipo_elemento.get_Parameter(BuiltInParameter.KEYNOTE_PARAM);
                            Parameter param_C1 = tipo_elemento.LookupParameter("C1");

                            paramametro_C1 = param_C1.AsString();

                           
                            parametro_codigo = param_codigo.AsString();


                            Lista_codigo.Add(parametro_codigo);


                            Lista_C1.Add(param_C1.ToString());

                        } 

                        else
                        { TaskDialog.Show("Revit", "No is wall"); }

                        }&lt;/PRE&gt;&lt;P&gt;With this code when i do the rectangle selection add to list "Lista_tipo_elemento" all the element ,not only the wall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i look for some like....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;foreach (Element element in pickedElements)

                    {
                        if (element is Wall)
                        {......make list of wall........}

if (elem.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Windows)
{..........make list of windows........}&lt;/PRE&gt;&lt;P&gt;thanks¡¡¡&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 22:53:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6825826#M60789</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-23T22:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: filter elements after selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6827515#M60790</link>
      <description>&lt;P&gt;Dear Andrese,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would completely separate the picking from all further operations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Encapsulating it in a separate method might help, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  List&amp;lt;ElementId&amp;gt; PickWalls()
  {
    // pick the walls
    PickElementsByRectangle ...
    return ...
  }&lt;/PRE&gt;
&lt;P&gt;You can also add a selection filter argument to the pick method to limit the elements that can be picked to certain specific type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The filter can use any criteria you like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, as a newbie, have you worked through the getting started material yet?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/about-the-author.html#2" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/about-the-author.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That can save you and the rest of the universe a bunch of questions...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:51:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6827515#M60790</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-24T15:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: filter elements after selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6828729#M60791</link>
      <description>&lt;P&gt;yeah¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ thanks¡¡¡¡¡¡¡¡¡¡¡&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  IList&amp;lt;Element&amp;gt; pickedElements = uidoc.Selection.PickElementsByRectangle("Select by rectangle");
    
                if (pickedElements.Count &amp;gt; 0)
                {

                    foreach (Element element in pickedElements)

                    {
                        if (element is Wall)

                        { PickWalls.Add(element); 

                        }

                        if (element.Category.Id.IntegerValue == (int)BuiltInCategory.OST_Windows)
                            {
                            PickWindows.Add(element);
                        }
                    }

                    if (PickWalls.Count &amp;gt; 0)

                    {
                        foreach (Element muro in PickWalls)

                        {
                            ElementId id = muro.GetTypeId();
                           
					....get all the information...
                            
   
                        }

                    }


                    if (PickWindows.Count &amp;gt; 0)

                    {
                        foreach (Element ventana in PickWindows)

                        {

                            ElementId id = ventana.GetTypeId();
                            ....get all the information...
                        }


                    }&lt;/PRE&gt;&lt;P&gt;Thank you !!!!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and thanks for the link of getting started material&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 22:59:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6828729#M60791</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-24T22:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: filter elements after selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6829272#M60792</link>
      <description>&lt;P&gt;Thank you for the appreciation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Glad it helped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your call to the pick method, you can still add a selection filter as well:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.revitapidocs.com/2017/d552f44b-221c-0ecd-d001-41a5099b2f9f.htm" target="_blank"&gt;http://www.revitapidocs.com/2017/d552f44b-221c-0ecd-d001-41a5099b2f9f.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would simplify the picking interaction for the user and guarantee that you receive nothing but wall and window elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.revitapidocs.com/2017/9c967926-c396-6e6b-97a2-b6882d71b69e.htm" target="_blank"&gt;http://www.revitapidocs.com/2017/9c967926-c396-6e6b-97a2-b6882d71b69e.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  bool AllowElement(Element e )
  {
    return e is Wall 
      || (null != e.Category &amp;amp;&amp;amp; e.Category.Id.IntegerValue == ...
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 07:07:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6829272#M60792</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-25T07:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: filter elements after selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6830929#M60793</link>
      <description>&lt;P&gt;thanks!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i continuos learning....&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 18:29:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-after-selection/m-p/6830929#M60793</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-25T18:29:36Z</dc:date>
    </item>
  </channel>
</rss>

