Managed exception thrown by Revit/other app - Filled Region Creation via Python

I am getting an exception thrown from trying to create a filled region; I would like some understanding to the cause, and idea for considering solutions to problem.

Regards,

“Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 21, in
Exception: A managed exception was thrown by Revit or by one of its external applications.”

image

Is there a reason why you aren’t using the OOTB node for this?
image

It would be much more helpful to share an image of the graph and/or the actual graph. There are too many variables here to guess at.

I tried to at first, but every type of “regionType” would turn up an error.

image

Warning: One or more of the input types are not matching. Couldn’t find a version of ByCurves that takes arguments of type (Function,__array,Revit.Elements.FilledRegionType)

You don’t have a view. Document.ActiveView requires a doc input.
I also don’t remember if your boundary input has to be a closed polycurve or separate curves, but order would likely matter in the case of the latter.

The document was the issue for the OOTB node.

You need to make a curveloop with the API and retrieve a FilledRegionType.

import clr
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

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

boundaryCurves = IN[0]
filledRegionName = IN[1]

viewId = doc.ActiveView.Id

TransactionManager.Instance.EnsureInTransaction(doc)
for col in FilteredElementCollector(doc).OfClass(FilledRegionType):
	if Element.Name.GetValue(col) == filledRegionName:
		regionId = col.Id

curveLoop=[]
filledCurves = CurveLoop()
for curve in boundaryCurves:
	filledCurves.Append(curve.ToRevitType())
curveLoop.Add(filledCurves)

outRegion  = FilledRegion.Create(doc, regionId, viewId, curveLoop)
TransactionManager.Instance.TransactionTaskDone()

OUT = outRegion 	

4 Likes

Alban,

Thank you, this solved the issue, and gave me some more insight to the expecation of Revit’s wants for particular elements to satisfy its commands.

Regards,
Colby Evans

1 Like