# Filling Region between two circles

**URL:** <https://forum.dynamobim.com/t/filling-region-between-two-circles/44023>\
**Category:** Geometry\
**Tags:** dynamo\
**Created:** [December 4, 2019, 5:13pm UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023 "2019-12-04T17:13:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![alejandre](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alejandre](https://forum.dynamobim.com/u/alejandre)\
**Post date:** [December 4, 2019, 5:13pm UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/1 "2019-12-04T17:13:45Z")

</div>

Hi to everybody,

I am trying to fill a region between two circles with a Dynamo Script and I am not getting good results because I have the next issue.

> This curve will make the loop not contiguous.  
> Parameter name: pCurve

Someone knows how can I get solved the next issue?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/b/4b0e9adfa38c800e4a9e1983018325520371adca.png)  
 ![Anmerkung 2019-12-04 180711](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/c/0c3ee08e271376687741bfb2c19093577838c8f0.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [December 4, 2019, 5:27pm UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/2 "2019-12-04T17:27:09Z")

</div>

You have to create the hatch as a separate items and then edit the sketch accordingly. Good illustration of the process here: [I want to edit the sketch of an existing floor or slab - #3 by Dimitar\_Venkov](https://forum.dynamobim.com/t/i-want-to-edit-the-sketch-of-an-existing-floor-or-slab/9775/3)

---

<div class="post-metadata">

**Author:** ![alejandre](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alejandre](https://forum.dynamobim.com/u/alejandre)\
**Post date:** [December 4, 2019, 10:50pm UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/3 "2019-12-04T22:50:19Z")

</div>

Hi @jacob.small, thanks for the response.

I am getting Empty.Lists from this node.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/e/1edfee0345ea1edfbd272331c4edb90494cb76af.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [December 4, 2019, 11:40pm UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/4 "2019-12-04T23:40:38Z")

</div>

Because you aren’t sending a sketch based element just yet - you need to create a sketch based element (ie: a hatch) first, then set the location of the curves to the new location.

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [December 5, 2019, 6:06am UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/5 "2019-12-05T06:06:53Z")

</div>

There’s two issues that you’re facing.

The first one is that Revit can’t create sketches with a single closed curve and therefore you have to always split the curve into at least two segments. The second one is that the OOTB `FiledRegion.ByCurves` is exposed in a less than ideal way, compared to what is provided by the API and you’ll need to use a script instead:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/f/9f5ef47d1589d18280aaba0a35e4f9fa7bd474fa.png)

```
import clr

clr.AddReference('RevitAPI')
import Autodesk.Revit.DB as DB

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('System')
from System.Collections.Generic import List

view, dynLoops, type = UnwrapElement(IN)
OUT = []
rvtLoops = List[DB.CurveLoop]()
for crvs in dynLoops:
	loop = DB.CurveLoop.Create([c.ToRevitType() for c in crvs])
	rvtLoops.Add(loop)

TransactionManager.Instance.EnsureInTransaction(doc)
fr = DB.FilledRegion.Create(doc, type.Id, view.Id, rvtLoops)
OUT.append(fr.ToDSType(False) )
TransactionManager.Instance.TransactionTaskDone()
```

---

<div class="post-metadata">

**Author:** ![alejandre](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alejandre](https://forum.dynamobim.com/u/alejandre)\
**Post date:** [December 5, 2019, 9:53am UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/6 "2019-12-05T09:53:55Z")

</div>

Ok…  
Amazing one more time. Thanks to all of you for the solutions @Dimitar_Venkov @jacob.small

---

<div class="post-metadata">

**Author:** ![alejandre](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alejandre](https://forum.dynamobim.com/u/alejandre)\
**Post date:** [December 5, 2019, 12:07pm UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/7 "2019-12-05T12:07:48Z")

</div>

Hi @Dimitar_Venkov and @jacob.small

Do you know why can I not give the filled Region Type from a List and only works with the node “Select Filled Region Type”?

The python node has the next issue in the line 27:

> Warnung:IronPythonEvaluator.EvaluateIronPythonScript fehlgeschlagen.  
> Traceback (most recent call last):  
> File “”, line 27, in   
> AttributeError: ‘List[object]’ object has no attribute ‘Id’

Is it possible to solved in this code?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/7/37dd53b76f6fa06d0500879181cd2307d1220dd7.png)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [December 6, 2019, 4:12am UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/8 "2019-12-06T04:12:03Z")

</div>

the code above expects a single value. Try using `List.FirstItem` or a codeblock with `mylist[0]`

---

<div class="post-metadata">

**Author:** ![alejandre](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alejandre](https://forum.dynamobim.com/u/alejandre)\
**Post date:** [December 6, 2019, 10:46am UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/9 "2019-12-06T10:46:05Z")

</div>

Works perfect with List.FirstItem.

Thanks a lot

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [December 6, 2019, 12:07pm UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/10 "2019-12-06T12:07:00Z")

</div>

> [@Dimitar\_Venkov](#):
>
> view, dynLoops, type = UnwrapElement(IN)

What is this madness? 😃

\*\*\*Squirrels this nugget away for future reference

Cheers,

Mark

---

<div class="post-metadata">

**Author:** ![GavinNicholls](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gavinnicholls/32/190442_2.png) [@GavinNicholls](https://forum.dynamobim.com/u/GavinNicholls)\
**Post date:** [January 24, 2022, 12:09am UTC](https://forum.dynamobim.com/t/filling-region-between-two-circles/44023/11 "2022-01-24T00:09:31Z")

</div>

Received a request from a user by email to elaborate on this workflow so it handles multiple rooms with loops for each room (more than one curve potentially). Workflow below for others to reference if needed in future. Broke a few of the one liners into loops so people can follow the list comprehensions more clearly.

```auto
# boilerplate
import clr

clr.AddReference('RevitAPI')
import Autodesk.Revit.DB as DB

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('System')
from System.Collections.Generic import List

# intial variables
rooms_list = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
type = UnwrapElement(IN[2])
curve_loops,regions = [],[]

# build curveloops for each room
for room in rooms_list:
	# initiate curveloop
	roomLoops = List[DB.CurveLoop]()
	# make curveloops
	for crv_list in room:
		rvt_crvs = []
		for c in crv_list:
			rvt_crvs.append(c.ToRevitType())
		loop = DB.CurveLoop.Create(rvt_crvs)
		roomLoops.Add(loop)
	#append curveloop to room loops
	curve_loops.append(roomLoops)

# create filled regions by room loops
TransactionManager.Instance.EnsureInTransaction(doc)

# make filled region in view for each curve loop
for c in curve_loops:
	fr = DB.FilledRegion.Create(doc, type.Id, view.Id, c)
	regions.append(fr.ToDSType(False))

TransactionManager.Instance.TransactionTaskDone()

# output is regions
OUT = regions

```

 ![workflow](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/e/1e0354fafca9a7ed196afa53825ddd0eca13cb1e.png)
