<?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: Creating Holes inside Filled Regions in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8834375#M41921</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Dear Mohsen,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your interesting query, appreciation for the blog, and for moving this discussion out from our private email conversation here into the public discussion forum.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First question: is it possible to create a filled region with holes or multiple separated boundaries manually through the user interface?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If not, the Revit API will probably not support this either.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If yes, generate such a model manually and use RevitLookup to analyse the filled region geometry in detail.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Maybe you can discover how such loops are arranged and stored in the manually generated case, and maybe that will give us hints on how to achieve the same programmatically as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jun 2019 16:09:01 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2019-06-05T16:09:01Z</dc:date>
    <item>
      <title>Creating Holes inside Filled Regions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8833944#M41920</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a co-op programming student at an architecture firm and I am currently working on an add-in that creates shadows that are filled regions. The way the shadow is created is by using the ExtrusionAnalyzer.Create() method, which takes the solid, a 0,0,0 plane, and the sun ray vector that is taken from the sun settings (Credits go to the very kind Jeremy Tammik from his blog post here:&amp;nbsp;&lt;A href="https://thebuildingcoder.typepad.com/blog/2013/06/sun-direction-shadow-calculation-and-wizard-update.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2013/06/sun-direction-shadow-calculation-and-wizard-update.html&lt;/A&gt;)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also using the clipper library to do boolean operations such as subtracting a buildings' footprint from the shadow that it casts, and outlining intersecting shadows from 2 buildings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However my main problem comes when I am creating my Filled Regions. It seems that it will only ever take 1 list of continuous loops, which means I am not able to create holes in my filled regions, nor am I able to have 2 or more sets of boundaries for the FilledRegion.Create() method, since the way it seems that clipper handles the boolean operations only makes it return 1 list of continuous curves that are connected. An example can be seen below, with the circled area being when I want a hole to be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Filled Regions created using my app" style="width: 885px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/644242i539DF182E0DB41B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="ShadowStudy.jpg" alt="Filled Regions created using my app" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Filled Regions created using my app&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Buildings being used to test my app" style="width: 885px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/644243i4A8C6C3BC7818497/image-size/large?v=v2&amp;amp;px=999" role="button" title="Buildings.jpg" alt="Buildings being used to test my app" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Buildings being used to test my app&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So to reiterate my question: Is it possible to create a filled region with holes or multiple separated boundaries programmatically?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Revit 2018.3 and the Revit 2018.2 SDK&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for reading through my post.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 13:41:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8833944#M41920</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-05T13:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Holes inside Filled Regions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8834375#M41921</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Mohsen,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your interesting query, appreciation for the blog, and for moving this discussion out from our private email conversation here into the public discussion forum.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First question: is it possible to create a filled region with holes or multiple separated boundaries manually through the user interface?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If not, the Revit API will probably not support this either.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If yes, generate such a model manually and use RevitLookup to analyse the filled region geometry in detail.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Maybe you can discover how such loops are arranged and stored in the manually generated case, and maybe that will give us hints on how to achieve the same programmatically as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 16:09:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8834375#M41921</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-06-05T16:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Holes inside Filled Regions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8842799#M41922</link>
      <description>&lt;P&gt;I have managed to figure this out, though with some interesting notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that Revit automatically detects if the boundaries passed into a filled region are representing holes or not. For example, if a closed loop of curves is found within another closed loop of curves, Revit will automatically render it as a hole. However, boundaries that are touching or intersecting each other will prevent the filled region from being created and will cause Revit to throw an error. This is something to note because though the clipper library supports such an arbitrary case, Revit does not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I was doing before was returning only 1 path of closed loops (a contour according to the clipper library terminology), which was incorrect. Instead I iterated through all of the paths returned from the clipper object that does the Boolean functions and was able to collect all of the boundaries that I needed to render more correct shadows.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 17:32:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8842799#M41922</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-10T17:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Holes inside Filled Regions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8843131#M41923</link>
      <description>&lt;P&gt;Thank you very much for discovering and describing the solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide a minimal sample code snippet illustrating the creation of a filled region with a hole in it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 20:09:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8843131#M41923</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-06-10T20:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Holes inside Filled Regions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8843162#M41924</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the minimum code snippet for creating a Filled Region with holes in it. I put the name for the draft view and region type as Level 1 Shadows and Shadow Proposed as it was already available in my document, but you can change it to whatever is convenient for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var doc = ActiveUIDocument.Document;&lt;BR /&gt;//Getting the view where we want the filled region to be drawn
var draftView = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views).First(n=&amp;gt;n.Name=="Level 1 Shadows");&lt;BR /&gt;//Getting the region type for the filled region
var regionType = new FilteredElementCollector(doc).OfClass(typeof(FilledRegionType)).First(f=&amp;gt;f.Name=="Shadow Proposed");
//Boundaries of the filled region			
List&amp;lt;CurveLoop&amp;gt; profileLoops = new List&amp;lt;CurveLoop&amp;gt;();&lt;BR /&gt;&lt;BR /&gt;//Coordinates of the outer loop			
XYZ[] points = new XYZ[5];
points[0] = new XYZ(0.0,0.0,0.0);
points[1] = new XYZ(100.0,0.0,0.0);
points[2] = new XYZ(100.0,100.0,0.0);
points[3] = new XYZ(0.0,100.0,0.0);
points[4] = new XYZ(0.0,0.0,0.0);
&lt;BR /&gt;//Connecting the points of the outer loop
CurveLoop outerLoop = new CurveLoop();
for (int i = 0; i &amp;lt; 4; i++)&lt;BR /&gt;{
	Line line = Line.CreateBound(points[i], points[i+1]);
	outerLoop.Append(line);
}&lt;BR /&gt;//Adding outer loop to the boundaries of the filled region
profileLoops.Add(outerLoop);&lt;BR /&gt;&lt;BR /&gt;//Coordinates of the inner loop
XYZ[] points2 = new XYZ[5];
points2[0] = new XYZ(25.0,25.0,0.0);
points2[1] = new XYZ(50.0,25.0,0.0);
points2[2] = new XYZ(50.0,50.0,0.0);
points2[3] = new XYZ(25.0,50.0,0.0);
points2[4] = new XYZ(25.0,25.0,0.0);
&lt;BR /&gt;//Connecting the points of the inner loop
CurveLoop innerLoop = new CurveLoop();
for (int i = 0; i &amp;lt; 4; i++) {			
	Line line = Line.CreateBound(points2[i], points2[i+1]);
	innerLoop.Append(line);&lt;BR /&gt;}&lt;BR /&gt;//Adding the inner loop to the filled region
profileLoops.Add(innerLoop);
&lt;BR /&gt;//Creating the filled region			
Transaction tr = new Transaction(doc,"Create Filled Region");
tr.Start();
var region = FilledRegion.Create(doc,regionType.Id,draftView.Id,profileLoops);
tr.Commit();&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, 10 Jun 2019 20:22:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8843162#M41924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-10T20:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Holes inside Filled Regions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8843829#M41925</link>
      <description>&lt;P&gt;Dear Mohsen,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks perfect, and will hopefully be useful for others encountering this issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 07:12:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/8843829#M41925</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-06-11T07:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Holes inside Filled Regions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/12852237#M41926</link>
      <description>&lt;P&gt;Did "FilledRegion.Create" change again, I can no longer get the code above to work. I am using Revit 2021. I keep getting an error saying "Boundaries are self-intersecting" no matter what I try.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 18:27:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/creating-holes-inside-filled-regions/m-p/12852237#M41926</guid>
      <dc:creator>MiguelVJC82W</dc:creator>
      <dc:date>2024-06-20T18:27:02Z</dc:date>
    </item>
  </channel>
</rss>

