RIR Python Component - Cast Area to Surface/ Brep

tldr: What I’d really like to do is use Area objects as inputs in a Python script, then get their trimmed surface/ region representation within the Python code

The best method I’ve found for reliably getting a Revit Area as a “region” is to pass the area into a surface param component. This is able to accurately represent the Area including any cut-outs. If I get the Area Boundaries instead, it sometimes results in multiple edge loops or open curves (Revit closes small gaps, but I do not see a property to obtain this “gap closed” representation of the Area).

I am currently using a python component to search through Area objects and find one that contains a point3d. Specifically, I am casting the Area to a surface outside of the python component, then type-hinting that surface as a Brep on the Python input (the type-hinting seems to be required or else the output surface becomes untrimmed).

What I’d really like to do is use the Area objects as inputs in the Python script, then get their trimmed surface representation within the Python code, so when the correct area is found, I can return the Area object itself (for further use downstream). Is there a way to do so?

  1. The RIR Geometry Encoder/ Decoder does not have a method for Areas, and the Revit class does not seem to have a property for the Area’s “gap closed” representation.
  2. I see in the Area component on Github, it is listed as being castable to surface, but I’m not sure how to activate that casting.
    Rhino Inside Github

I may be missing something obvious as I’m still learning Python…

Hi @Matthew_Breau1,

Maybe ‘Query Areas’ may help you to pre-filter areas by a point.

One quick solution to have both the Area an the Surface in the Python component may be add an additional parameter of type Brep in parallel with the areas input.

The hardest alternative would be build the surface like RiR does from SpatialElement.GetBoundarySegments.

This method gives you a collection of segments that need to be converted to Rhino.Geometry.Curve then joined using Curve.JoinCurves once you have the curves joined in closed loops you can use Brep.CreatePlanarBreps to create the resulting Brep.

Thanks Kike, the QueryAreas component gives me this error:

Here is my version info:
image

The parallel inputs approach sounds easiest, so Ill most likely go with that…

Out of curiosity, are parameter components available through node in code? Maybe something like this:

surface_param = Components.FindComponent("Surface")
area_as_surf = surface_param .Invoke(Area)

Matthew, What version of Revit are you running?

I’ll roll back to 1.11.84 and try in the Revit Version you are in. Thanks

@Matthew_Breau1,

Not sure if NodeInCode is able to run parameters, but I don’t think it would work because your Area is already an Autodesk.Revit.DB.Area in Python and is no more a GH type.

I did some changes in v1.13 that may help with the error message you showed on ‘Query Areas’.

Could you please test with v1.13?

@Japhy, I’m in Revit 2022.1

@kike, sure I’ll try v1.12 RC4 shortly

@kike
I tried v1.12 and got the same error
Tried the daily build (1.13.8439.22370) and it seems to work (no errors)

1 Like

Perfect Thanks.

This means is fixed, because the fix will be on 1.12 next Tuesday but is already in v1.13

1 Like

Awesome, thanks @kike
Playing with it a little more, adding the parameters through the ZUI, if “Enclosed” is True then I get the memory error again…
Is there any chance an “Area Scheme(s)” filter could be part of the Query Areas component as well?

Just to wrap up my original question for posterity, it seems like passing parallel lists (Area object + area surface representation) through the python node has some drawbacks. The Revit objects (or their GH wrappers) get a little mutilated and the Areas need to be re-acquired from Revit in order to get “fixed”.

So I’ll probably just pass in element IDs, then use the IDs to re-acquire the objects after the Python node.

@Matthew_Breau1,

Next v1.13 has a ‘Query Area Schemes’ component and the additional input you requested.

I also added some changes to try to address the problem you mentioned previously when using the enclosed input.

If it is not fixed do you mind testing on a simpler file and see.
Maybe there is a wild Area in your file that is ill formed, unplaced or not properly enclosed that is causing this.

Please give it a try.