Filling Region between two circles

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?


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

Hi @jacob.small, thanks for the response.

I am getting Empty.Lists from this node.

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.

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:

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()
9 Likes

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

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?

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

1 Like

Works perfect with List.FirstItem.

Thanks a lot

What is this madness? :smiley:

***Squirrels this nugget away for future reference

Cheers,

Mark

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.

# 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

4 Likes