<?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: Retrieving all elements in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/retrieving-all-elements/m-p/3378963#M80955</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should help to get back "all" the elements:&amp;nbsp;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/filter-for-all-elements.html" target="_self"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/filter-for-all-elements.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But actually it seems you only need the visible elements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="code" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; white-space: pre-wrap; background-color: #f7f7f7; overflow-x: scroll; border-width: 1px; border-color: #dadada; border-style: dotted; padding: 5px;"&gt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;IList&lt;/SPAN&gt;&amp;lt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt;&amp;gt; GetAllModelElements( &lt;SPAN class="teal" style="line-height: 1.2;"&gt;Document&lt;/SPAN&gt; doc )
{
&amp;nbsp; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt;&amp;gt; elements = &lt;SPAN class="blue" style="line-height: 1.2;"&gt;new&lt;/SPAN&gt; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt;&amp;gt;();
&amp;nbsp;
&amp;nbsp; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;FilteredElementCollector&lt;/SPAN&gt; collector
&amp;nbsp; &amp;nbsp; = &lt;SPAN class="blue" style="line-height: 1.2;"&gt;new&lt;/SPAN&gt; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;FilteredElementCollector&lt;/SPAN&gt;( doc )
&amp;nbsp; &amp;nbsp; &amp;nbsp; .WhereElementIsNotElementType();
&amp;nbsp;
&amp;nbsp; &lt;SPAN class="blue" style="line-height: 1.2;"&gt;foreach&lt;/SPAN&gt;( &lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt; e &lt;SPAN class="blue" style="line-height: 1.2;"&gt;in&lt;/SPAN&gt; collector )
&amp;nbsp; {
&amp;nbsp; &amp;nbsp; &lt;SPAN class="blue" style="line-height: 1.2;"&gt;if&lt;/SPAN&gt;( &lt;SPAN class="blue" style="line-height: 1.2;"&gt;null&lt;/SPAN&gt; != e.Category
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; e.Category.HasMaterialQuantities )
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; elements.Add( e );
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }
&amp;nbsp; &lt;SPAN class="blue" style="line-height: 1.2;"&gt;return&lt;/SPAN&gt; elements;
}&lt;/PRE&gt;
&lt;P&gt;Then you need to retrieve the geometry from each element you are interested in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many topics on Jeremy's blog concerning this: &lt;A href="http://thebuildingcoder.typepad.com/blog/2010/01/analyse-building-geometry.html" target="_self"&gt;http://thebuildingcoder.typepad.com/blog/2010/01/analyse-building-geometry.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adam Nagy&lt;/P&gt;
&lt;P&gt;Autodesk Developer Network&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2012 00:50:03 GMT</pubDate>
    <dc:creator>adam.nagy</dc:creator>
    <dc:date>2012-03-21T00:50:03Z</dc:date>
    <item>
      <title>Retrieving all elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/retrieving-all-elements/m-p/3377715#M80954</link>
      <description>&lt;P&gt;Hey !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to retrieve all elements from the document (without the need of a user selection) to get all information about Face, Mesh, Vertex... I have to export those data to a rendering engine. I have no idea how to do that and the only exemples I found are about getting data from a selected element.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best !&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2012 11:43:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/retrieving-all-elements/m-p/3377715#M80954</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-20T11:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving all elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/retrieving-all-elements/m-p/3378963#M80955</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should help to get back "all" the elements:&amp;nbsp;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/filter-for-all-elements.html" target="_self"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/filter-for-all-elements.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But actually it seems you only need the visible elements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="code" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; white-space: pre-wrap; background-color: #f7f7f7; overflow-x: scroll; border-width: 1px; border-color: #dadada; border-style: dotted; padding: 5px;"&gt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;IList&lt;/SPAN&gt;&amp;lt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt;&amp;gt; GetAllModelElements( &lt;SPAN class="teal" style="line-height: 1.2;"&gt;Document&lt;/SPAN&gt; doc )
{
&amp;nbsp; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt;&amp;gt; elements = &lt;SPAN class="blue" style="line-height: 1.2;"&gt;new&lt;/SPAN&gt; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;List&lt;/SPAN&gt;&amp;lt;&lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt;&amp;gt;();
&amp;nbsp;
&amp;nbsp; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;FilteredElementCollector&lt;/SPAN&gt; collector
&amp;nbsp; &amp;nbsp; = &lt;SPAN class="blue" style="line-height: 1.2;"&gt;new&lt;/SPAN&gt; &lt;SPAN class="teal" style="line-height: 1.2;"&gt;FilteredElementCollector&lt;/SPAN&gt;( doc )
&amp;nbsp; &amp;nbsp; &amp;nbsp; .WhereElementIsNotElementType();
&amp;nbsp;
&amp;nbsp; &lt;SPAN class="blue" style="line-height: 1.2;"&gt;foreach&lt;/SPAN&gt;( &lt;SPAN class="teal" style="line-height: 1.2;"&gt;Element&lt;/SPAN&gt; e &lt;SPAN class="blue" style="line-height: 1.2;"&gt;in&lt;/SPAN&gt; collector )
&amp;nbsp; {
&amp;nbsp; &amp;nbsp; &lt;SPAN class="blue" style="line-height: 1.2;"&gt;if&lt;/SPAN&gt;( &lt;SPAN class="blue" style="line-height: 1.2;"&gt;null&lt;/SPAN&gt; != e.Category
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; e.Category.HasMaterialQuantities )
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; elements.Add( e );
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }
&amp;nbsp; &lt;SPAN class="blue" style="line-height: 1.2;"&gt;return&lt;/SPAN&gt; elements;
}&lt;/PRE&gt;
&lt;P&gt;Then you need to retrieve the geometry from each element you are interested in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many topics on Jeremy's blog concerning this: &lt;A href="http://thebuildingcoder.typepad.com/blog/2010/01/analyse-building-geometry.html" target="_self"&gt;http://thebuildingcoder.typepad.com/blog/2010/01/analyse-building-geometry.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adam Nagy&lt;/P&gt;
&lt;P&gt;Autodesk Developer Network&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 00:50:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/retrieving-all-elements/m-p/3378963#M80955</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2012-03-21T00:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving all elements</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/retrieving-all-elements/m-p/3379215#M80956</link>
      <description>&lt;P&gt;It works, thank you so much !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm not sure that I'm using it correctly. Here is my code:&lt;/P&gt;&lt;PRE&gt;UIApplication uiApplication = cmdData.Application;
                UIDocument uiDocument = uiApplication.ActiveUIDocument;

                List&amp;lt;double&amp;gt; listData = new List&amp;lt;double&amp;gt;();

                Options geoOptions = uiApplication.Application.Create.NewGeometryOptions();
                if (geoOptions != null)
                {
                    geoOptions.ComputeReferences = true;
                    geoOptions.DetailLevel = DetailLevels.Fine;
                }
                List&amp;lt;Element&amp;gt; elements = new List&amp;lt;Element&amp;gt;();
                FilteredElementCollector collector = new FilteredElementCollector(uiDocument.Document).WhereElementIsNotElementType();
                foreach (Element e in collector)
                {
                    if (e.Category != null &amp;amp;&amp;amp; e.Category.HasMaterialQuantities)
                    {
                        elements.Add(e);
                    }
                }
                foreach (Element elem in elements)
                {
                    GeometryElement geoElement = elem.get_Geometry(geoOptions);
                    // Get geometry object
                    foreach (GeometryObject geoObject in geoElement.Objects)
                    {
                        // Get the geometry instance which contains the geometry information
                        GeometryInstance geometryInstance = geoObject as GeometryInstance;
                        if (geometryInstance != null)
                        {
                            foreach (GeometryObject instObj in geometryInstance.SymbolGeometry.Objects)
                            {
                                Solid solid = instObj as Solid;
                                if (solid == null || solid.Faces.Size == 0)
                                {
                                    continue;
                                }
                                Transform transform = geometryInstance.Transform;

                                // Get the faces from solid
                                foreach (Face face in solid.Faces)
                                {
                                    Mesh mesh = face.Triangulate();
                                    foreach (XYZ point in mesh.Vertices)
                                    {
                                        listData.Add(point.X);
                                        listData.Add(point.Y);
                                        listData.Add(point.Z);
                                    }
                                }
                            }
                        }
                    }
                }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What about getting information about the Transformation ?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 09:48:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/retrieving-all-elements/m-p/3379215#M80956</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-21T09:48:42Z</dc:date>
    </item>
  </channel>
</rss>

