In our multi-family work we utilize areas inside of model groups to designate units within our buildings. Currently Revit does not allow tagging areas outside of Area Plans. I am aware of other workflows out there, but my proposed solution is to copy data from our 4 Area parameters to 4 parameters in our model groups. Currently the script will run flawlessly in a test environment and match the area to the group with no errors.
However, when run across a large project, even though it runs without errors, the data is not being copied from the area to the exact model group where the area is contained. Thus, the script copies data from an area within one group to a completely unrelated model group.
I need assistance in finding either a coordinate or point for the area and group to matchup to ensure the data matches 100%. Any insight into this would be appreciated. Image of the script is included below.
Best method I can think of is getting the union box of each group and comparing its centroid to the areas centroid using closest points.
Bounding box the model elements per group, cuboid them as lists, solid union those lists, bounding box those unions, cuboid the boxes, and solid centroid those. This will be the centroid of each model group.
For areas, get their level, match to a list of levels and their Z elevation. Get the area perimeter curves, patch them and get point at parameter 0.5,0.5. Reconstruct the points using the level elevations as their new Z value (reuse X/Y). Might be good to do the same for your model group centroids.
From there, find distance from each group to each area centroid, sort by key on the original areas and take the first item from each resulting list per group. That’ll be the closest one.
I think for area boundaries and model group elements you’ll need some custom nodes, but that works in my mind (not at my desk).