<?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: Create &amp;quot;solid&amp;quot; and find all elements within in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/create-quot-solid-quot-and-find-all-elements-within/m-p/6498994#M63526</link>
    <description>&lt;P&gt;Don't panic this is pretty simple to get Faces from a Solid of a geometry, try the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#region Namespaces

using System;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;

using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;

using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;

#endregion

namespace RevitAddinCS1
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class GeometryManager : IExternalCommand
    {
        #region Cached Variables

        private static ExternalCommandData _cachedCmdData;

        public static UIApplication CachedUiApp
        {
            get
            {
                return _cachedCmdData.Application;
            }
        }

        public static RvtApplication CachedApp
        {
            get
            {
                return CachedUiApp.Application;
            }
        }

        public static RvtDocument CachedDoc
        {
            get
            {
                return CachedUiApp.ActiveUIDocument.Document;
            }
        }

        #endregion

        #region IExternalCommand Members

        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            _cachedCmdData = cmdData;

            try
            {
                Reference reference = CachedUiApp.ActiveUIDocument.Selection.PickObject(ObjectType.Element);

                Element element = CachedDoc.GetElement(reference);

                Options geoOptions = new Options();

                // Get geometry element of the selected element
                GeometryElement geoElement = element.get_Geometry(geoOptions);

                // Get geometry object
                foreach (GeometryObject geoObject in geoElement)
                {
                    // Get the geometry instance which contains the geometry information
                    Autodesk.Revit.DB.GeometryInstance instance = geoObject as Autodesk.Revit.DB.GeometryInstance;

                    if (null != instance)
                    {
                        foreach (GeometryObject instObj in instance.SymbolGeometry)
                        {
                            Solid solid = instObj as Solid;

                            if (null == solid || 0 == solid.Faces.Size || 0 == solid.Edges.Size)
                            {
                                continue;
                            }

                            if (solid.Faces.Size &amp;gt; 0)
                            {
                                // Get the faces and edges from solid, and transform the formed points
                                foreach (Face face in solid.Faces)
                                {
                                    TaskDialog.Show("Revit", face.Area.ToString());
                                }
                            }
                        }
                    }
                }


                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return Result.Failed;
            }
        }

        #endregion
    }
}&lt;/PRE&gt;
&lt;P&gt;Just select the element and the code will show you how to retrieve the solid and its faces showing up a dialog with each face's area. You can of course replace the PickObject function with a filter or you can create a function where you can pass the element from which the faces will be extracted as a parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't forget to mark this reply as an answer if it satisfies your need.&lt;/P&gt;</description>
    <pubDate>Sun, 14 Aug 2016 09:58:45 GMT</pubDate>
    <dc:creator>Mustafa.Salaheldin</dc:creator>
    <dc:date>2016-08-14T09:58:45Z</dc:date>
    <item>
      <title>Create "solid" and find all elements within</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-quot-solid-quot-and-find-all-elements-within/m-p/6497595#M63524</link>
      <description>&lt;P&gt;Hey everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been searching for a while, but struggle to find an approach to the solution. I try to create a 3-dimensional "solid" (sorry for the bad english) and find all elements that are inside. That solid should best be assembled from faces. How would I do that with the API?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Until now I searched in the SDK Samples and &lt;A href="http://thebuildingcoder.typepad.com/blog/2010/01/geometry-options.html" target="_blank"&gt;here&lt;/A&gt;, but I don't even know if I'm searching in the right direction. I'd really appreciate any hints where to start. Might it be necessary to create a family for such a "control solid"? If yes, I'd also appreciate every hint here!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 20:07:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-quot-solid-quot-and-find-all-elements-within/m-p/6497595#M63524</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-12T20:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create "solid" and find all elements within</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-quot-solid-quot-and-find-all-elements-within/m-p/6498342#M63525</link>
      <description>Hey again,&lt;BR /&gt;&lt;BR /&gt;I'm still on the topic and just wanted to post my progress:&lt;BR /&gt;I managed to create a new family via GUI that is based on the template "Metric Generic Model face based.rft" that looks close to what I want to create with the API. I then inserted it (also via GUI) into the Revit Architecture Sample Project and now try to find out which elements are intersecting. While that is obvious in the 3D-view, it's again not so easy to get with the API. I tried &lt;A href="http://thebuildingcoder.typepad.com/blog/2010/12/find-intersecting-elements.html" target="_blank"&gt;this&lt;/A&gt; and the results were as expected, but since I don't need the intersection with the bounding box but with the geometry that was not useful for me. I then found &lt;A href="http://thebuildingcoder.typepad.com/blog/2014/11/determining-intersecting-elements-and-continued-futureproofing.html#3" target="_blank"&gt;this&lt;/A&gt; and copy-pasted from the Revit API help file to use the "ElementIntersectsElementFilter" and the "ElementIntersectsSolidFilter" classes. Unfortunately the results aren't as expected and now I think about "creating a solid from scratch using the routines in GeometryCreationUtilities" like the help file suggests.&lt;BR /&gt;&lt;BR /&gt;I would still appreciate any help since I'm really not very experienced with the Revit API and expect that there has to be an easier way to achieve all this!?&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Sat, 13 Aug 2016 15:37:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-quot-solid-quot-and-find-all-elements-within/m-p/6498342#M63525</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-13T15:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create "solid" and find all elements within</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-quot-solid-quot-and-find-all-elements-within/m-p/6498994#M63526</link>
      <description>&lt;P&gt;Don't panic this is pretty simple to get Faces from a Solid of a geometry, try the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#region Namespaces

using System;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;

using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;

using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;

#endregion

namespace RevitAddinCS1
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class GeometryManager : IExternalCommand
    {
        #region Cached Variables

        private static ExternalCommandData _cachedCmdData;

        public static UIApplication CachedUiApp
        {
            get
            {
                return _cachedCmdData.Application;
            }
        }

        public static RvtApplication CachedApp
        {
            get
            {
                return CachedUiApp.Application;
            }
        }

        public static RvtDocument CachedDoc
        {
            get
            {
                return CachedUiApp.ActiveUIDocument.Document;
            }
        }

        #endregion

        #region IExternalCommand Members

        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            _cachedCmdData = cmdData;

            try
            {
                Reference reference = CachedUiApp.ActiveUIDocument.Selection.PickObject(ObjectType.Element);

                Element element = CachedDoc.GetElement(reference);

                Options geoOptions = new Options();

                // Get geometry element of the selected element
                GeometryElement geoElement = element.get_Geometry(geoOptions);

                // Get geometry object
                foreach (GeometryObject geoObject in geoElement)
                {
                    // Get the geometry instance which contains the geometry information
                    Autodesk.Revit.DB.GeometryInstance instance = geoObject as Autodesk.Revit.DB.GeometryInstance;

                    if (null != instance)
                    {
                        foreach (GeometryObject instObj in instance.SymbolGeometry)
                        {
                            Solid solid = instObj as Solid;

                            if (null == solid || 0 == solid.Faces.Size || 0 == solid.Edges.Size)
                            {
                                continue;
                            }

                            if (solid.Faces.Size &amp;gt; 0)
                            {
                                // Get the faces and edges from solid, and transform the formed points
                                foreach (Face face in solid.Faces)
                                {
                                    TaskDialog.Show("Revit", face.Area.ToString());
                                }
                            }
                        }
                    }
                }


                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return Result.Failed;
            }
        }

        #endregion
    }
}&lt;/PRE&gt;
&lt;P&gt;Just select the element and the code will show you how to retrieve the solid and its faces showing up a dialog with each face's area. You can of course replace the PickObject function with a filter or you can create a function where you can pass the element from which the faces will be extracted as a parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't forget to mark this reply as an answer if it satisfies your need.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Aug 2016 09:58:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-quot-solid-quot-and-find-all-elements-within/m-p/6498994#M63526</guid>
      <dc:creator>Mustafa.Salaheldin</dc:creator>
      <dc:date>2016-08-14T09:58:45Z</dc:date>
    </item>
  </channel>
</rss>

