<?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 Mass From Room in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/5452853#M80275</link>
    <description>&lt;P&gt;I believe this Code will retrieve the flat extrusion of a room object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes rooms are cut off by pitched roofs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Get Geometry is used from the API, can the Room Solids be simply be put into a mass family?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below example of beam.get_Geometry(options)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use rooms.get_Geometry(options):&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="saveHistory"&gt;&lt;DIV class="section"&gt;&lt;DIV class="code"&gt;&lt;PRE&gt;&lt;SPAN class="highlight-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="highlight-keyword"&gt;void&lt;/SPAN&gt; GetCurvesFromABeam(Autodesk.Revit.DB.FamilyInstance beam,
                               Autodesk.Revit.DB.Options options)
{
    Autodesk.Revit.DB.GeometryElement geomElem = beam.get_Geometry(options);

    Autodesk.Revit.DB.CurveArray curves = &lt;SPAN class="highlight-keyword"&gt;new&lt;/SPAN&gt; CurveArray();
    Autodesk.Revit.DB.SolidArray solids = &lt;SPAN class="highlight-keyword"&gt;new&lt;/SPAN&gt; SolidArray();

    &lt;SPAN class="highlight-comment"&gt;//Find all solids and insert them into solid array&lt;/SPAN&gt;
    AddCurvesAndSolids(geomElem, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; curves, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; solids);
}

&lt;SPAN class="highlight-keyword"&gt;private&lt;/SPAN&gt; &lt;SPAN class="highlight-keyword"&gt;void&lt;/SPAN&gt; AddCurvesAndSolids(Autodesk.Revit.DB.GeometryElement geomElem,
                                &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; Autodesk.Revit.DB.CurveArray curves,
                                &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; Autodesk.Revit.DB.SolidArray solids)
{
    &lt;SPAN class="highlight-keyword"&gt;foreach&lt;/SPAN&gt; (Autodesk.Revit.DB.GeometryObject geomObj &lt;SPAN class="highlight-keyword"&gt;in&lt;/SPAN&gt; geomElem)
    {
        Autodesk.Revit.DB.Curve curve = geomObj &lt;SPAN class="highlight-keyword"&gt;as&lt;/SPAN&gt; Autodesk.Revit.DB.Curve;
        &lt;SPAN class="highlight-keyword"&gt;if&lt;/SPAN&gt; (&lt;SPAN class="highlight-keyword"&gt;null&lt;/SPAN&gt; != curve)
        {
            curves.Append(curve);
            &lt;SPAN class="highlight-keyword"&gt;continue&lt;/SPAN&gt;;
        }
        Autodesk.Revit.DB.Solid solid = geomObj &lt;SPAN class="highlight-keyword"&gt;as&lt;/SPAN&gt; Autodesk.Revit.DB.Solid;
        &lt;SPAN class="highlight-keyword"&gt;if&lt;/SPAN&gt; (&lt;SPAN class="highlight-keyword"&gt;null&lt;/SPAN&gt; != solid)
        {
            solids.Append(solid);
            &lt;SPAN class="highlight-keyword"&gt;continue&lt;/SPAN&gt;;
        }
        &lt;SPAN class="highlight-comment"&gt;//If this GeometryObject is Instance, call AddCurvesAndSolids&lt;/SPAN&gt;
        Autodesk.Revit.DB.GeometryInstance geomInst = geomObj &lt;SPAN class="highlight-keyword"&gt;as&lt;/SPAN&gt; Autodesk.Revit.DB.GeometryInstance;
        &lt;SPAN class="highlight-keyword"&gt;if&lt;/SPAN&gt; (&lt;SPAN class="highlight-keyword"&gt;null&lt;/SPAN&gt; != geomInst)
        {
            Autodesk.Revit.DB.GeometryElement transformedGeomElem
              = geomInst.GetInstanceGeometry(geomInst.Transform);
            AddCurvesAndSolids(transformedGeomElem, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; curves, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; solids);
        }
    }
}&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 25 Dec 2014 12:43:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-12-25T12:43:21Z</dc:date>
    <item>
      <title>Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3674458#M80267</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I'm a bit out of my comfort zone here.&amp;nbsp; I am creating an addin which involves creating a mass for each instance of room.&amp;nbsp; I cobbled together the code below from examples on other blogs / sites (mostly &lt;A target="_blank" href="http://revitnet.blogspot.co.uk/2011/02/rest-of-convert-rooms-to-3d-masses.html"&gt;here&lt;/A&gt;).&amp;nbsp; This works but only if the room hasn't got any internal boundaries (holes, islands, etc).&amp;nbsp; If a room has an internal boundary the actual NewExtrution line fails with the error "One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument.".&amp;nbsp; I'm guessing this is because the profile array has more than one profile (like internal boundaries in this case).&amp;nbsp; The boundaries don't overlap though, just some are entirely consumed by others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone&amp;nbsp;know of a better approach here?&amp;nbsp; Or how to amend the code below to deal with the internal boundaries (holes) in the room?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Create family doc from template
Autodesk.Revit.DB.Document familyDoc = app.NewFamilyDocument(@"C:\ProgramData\Autodesk\RVT 2013\Family Templates\English\Metric Generic Model.rft");

// Save the new Family - room is Room Element not defined in this sample code
string fileName = @"C:\Temp\" + room.UniqueId.ToString() + ".rfa";
familyDoc.SaveAs(fileName);

Transaction transaction = new Transaction(familyDoc, "RoomToMass");
transaction.Start();

// Get the room boundary
SpatialElementBoundaryOptions opt = new SpatialElementBoundaryOptions();

IList&amp;lt;IList&amp;lt;Autodesk.Revit.DB.BoundarySegment&amp;gt;&amp;gt; segArray = room.GetBoundarySegments(opt);

CurveArray curveArray = new CurveArray();

// Iterate to gather the curve objects
foreach (IList&amp;lt;Autodesk.Revit.DB.BoundarySegment&amp;gt; bSegments in segArray)
{
    foreach (Autodesk.Revit.DB.BoundarySegment bSegment in bSegments)
    {
        curveArray.Append(bSegment.Curve);
    }
}

// Origin point and normal point that gives the extrusion direction
XYZ ptOrigin = new XYZ(0, 0, 0);
XYZ ptNormal = new XYZ(0, 0, 1);

// The plane to extrude the mass from
Plane plane = app.Create.NewPlane(ptNormal, ptOrigin);
SketchPlane sketchPlane = familyDoc.FamilyCreate.NewSketchPlane(plane);

// Add the CurveArray to a CurveArrArray
CurveArrArray curveArrArray = new CurveArrArray();
curveArrArray.Append(curveArray);

// Extrude the form 10 feet as test
Extrusion extrusion = familyDoc.FamilyCreate.NewExtrusion(true, curveArrArray, sketchPlane, 10);

transaction.Commit();

familyDoc.Save();

// now need to place the family...&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2012 20:02:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3674458#M80267</guid>
      <dc:creator>grahamcook</dc:creator>
      <dc:date>2012-10-25T20:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3674554#M80268</link>
      <description>&lt;P&gt;Hello Graham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it an option to create new model lines that outline the outer periphery/shell of the room using the room's boundary segments&amp;nbsp;(instead of directly using the curves of the room boundary segments) and then use this set of curves in a curvearray to create the mass element.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2012 21:01:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3674554#M80268</guid>
      <dc:creator>saikat</dc:creator>
      <dc:date>2012-10-25T21:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3674582#M80269</link>
      <description>&lt;P&gt;Saikat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for looking at my post.&lt;/P&gt;&lt;P&gt;Yes that would be an option i could look at.&amp;nbsp; If i knew how to just get the boundary of the OUTER edge only - ignoring all the inner boundaries.&amp;nbsp; Any Pointers?&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;Graham&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2012 21:27:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3674582#M80269</guid>
      <dc:creator>grahamcook</dc:creator>
      <dc:date>2012-10-25T21:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3675930#M80270</link>
      <description>&lt;P&gt;Hello Graham&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would an approach similar to what is being discussed here be of help/use:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do let us know if this worked out or not. Or if you found any other approach, better still.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cheers&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2012 20:19:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3675930#M80270</guid>
      <dc:creator>saikat</dc:creator>
      <dc:date>2012-10-26T20:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3676776#M80271</link>
      <description>&lt;P&gt;Thank you Saikat.&amp;nbsp; In this case i went with assuming the first segment set in the collection was the outer boundary and inserted a break in the first foreach loop to force a break after first loop.&amp;nbsp; I've tested on hundreds of rooms and the first segment set has always been the outer edge (so far).&amp;nbsp; I would like to eventually include holes within the mass but for this particular problem just the outer edge will suffice.&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;Graham&lt;/P&gt;</description>
      <pubDate>Sun, 28 Oct 2012 19:27:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3676776#M80271</guid>
      <dc:creator>grahamcook</dc:creator>
      <dc:date>2012-10-28T19:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3677926#M80272</link>
      <description>&lt;P&gt;Great! Thanks for the update.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;kind regards&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2012 17:58:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/3677926#M80272</guid>
      <dc:creator>saikat</dc:creator>
      <dc:date>2012-10-29T17:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/5452783#M80273</link>
      <description>&lt;P&gt;I am trying to comile this code in Visual Studio Express 2013.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to compile for Revit 2014&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the Class that goes avove&amp;nbsp;this code block?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Origin point and normal point that gives the extrusion direction
XYZ ptOrigin = new XYZ(0, 0, 0);
XYZ ptNormal = new XYZ(0, 0, 1);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Dec 2014 06:56:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/5452783#M80273</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-25T06:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/5452784#M80274</link>
      <description>&lt;P&gt;What are the classes I need to incorporate to make this code work for Revit 2014 addin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, can I compile this for Dynamo?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the code as pasted above is missing the following class:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public Extrusion NewExtrusion(&lt;BR /&gt;bool isSolid,&lt;BR /&gt;CurveArrArray profile,&lt;BR /&gt;SketchPlane sketchPlane,&lt;BR /&gt;double end&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Dec 2014 07:00:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/5452784#M80274</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-25T07:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create Mass From Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/5452853#M80275</link>
      <description>&lt;P&gt;I believe this Code will retrieve the flat extrusion of a room object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes rooms are cut off by pitched roofs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Get Geometry is used from the API, can the Room Solids be simply be put into a mass family?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below example of beam.get_Geometry(options)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to use rooms.get_Geometry(options):&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="saveHistory"&gt;&lt;DIV class="section"&gt;&lt;DIV class="code"&gt;&lt;PRE&gt;&lt;SPAN class="highlight-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="highlight-keyword"&gt;void&lt;/SPAN&gt; GetCurvesFromABeam(Autodesk.Revit.DB.FamilyInstance beam,
                               Autodesk.Revit.DB.Options options)
{
    Autodesk.Revit.DB.GeometryElement geomElem = beam.get_Geometry(options);

    Autodesk.Revit.DB.CurveArray curves = &lt;SPAN class="highlight-keyword"&gt;new&lt;/SPAN&gt; CurveArray();
    Autodesk.Revit.DB.SolidArray solids = &lt;SPAN class="highlight-keyword"&gt;new&lt;/SPAN&gt; SolidArray();

    &lt;SPAN class="highlight-comment"&gt;//Find all solids and insert them into solid array&lt;/SPAN&gt;
    AddCurvesAndSolids(geomElem, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; curves, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; solids);
}

&lt;SPAN class="highlight-keyword"&gt;private&lt;/SPAN&gt; &lt;SPAN class="highlight-keyword"&gt;void&lt;/SPAN&gt; AddCurvesAndSolids(Autodesk.Revit.DB.GeometryElement geomElem,
                                &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; Autodesk.Revit.DB.CurveArray curves,
                                &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; Autodesk.Revit.DB.SolidArray solids)
{
    &lt;SPAN class="highlight-keyword"&gt;foreach&lt;/SPAN&gt; (Autodesk.Revit.DB.GeometryObject geomObj &lt;SPAN class="highlight-keyword"&gt;in&lt;/SPAN&gt; geomElem)
    {
        Autodesk.Revit.DB.Curve curve = geomObj &lt;SPAN class="highlight-keyword"&gt;as&lt;/SPAN&gt; Autodesk.Revit.DB.Curve;
        &lt;SPAN class="highlight-keyword"&gt;if&lt;/SPAN&gt; (&lt;SPAN class="highlight-keyword"&gt;null&lt;/SPAN&gt; != curve)
        {
            curves.Append(curve);
            &lt;SPAN class="highlight-keyword"&gt;continue&lt;/SPAN&gt;;
        }
        Autodesk.Revit.DB.Solid solid = geomObj &lt;SPAN class="highlight-keyword"&gt;as&lt;/SPAN&gt; Autodesk.Revit.DB.Solid;
        &lt;SPAN class="highlight-keyword"&gt;if&lt;/SPAN&gt; (&lt;SPAN class="highlight-keyword"&gt;null&lt;/SPAN&gt; != solid)
        {
            solids.Append(solid);
            &lt;SPAN class="highlight-keyword"&gt;continue&lt;/SPAN&gt;;
        }
        &lt;SPAN class="highlight-comment"&gt;//If this GeometryObject is Instance, call AddCurvesAndSolids&lt;/SPAN&gt;
        Autodesk.Revit.DB.GeometryInstance geomInst = geomObj &lt;SPAN class="highlight-keyword"&gt;as&lt;/SPAN&gt; Autodesk.Revit.DB.GeometryInstance;
        &lt;SPAN class="highlight-keyword"&gt;if&lt;/SPAN&gt; (&lt;SPAN class="highlight-keyword"&gt;null&lt;/SPAN&gt; != geomInst)
        {
            Autodesk.Revit.DB.GeometryElement transformedGeomElem
              = geomInst.GetInstanceGeometry(geomInst.Transform);
            AddCurvesAndSolids(transformedGeomElem, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; curves, &lt;SPAN class="highlight-keyword"&gt;ref&lt;/SPAN&gt; solids);
        }
    }
}&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 Dec 2014 12:43:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-mass-from-room/m-p/5452853#M80275</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-25T12:43:21Z</dc:date>
    </item>
  </channel>
</rss>

