Visual Center for Rooms

Hi everyone,

I’m trying to get the visual center of rooms for centering them. The scripts I have found are based on the solids.centroid function but this doesn’t work for L-shaped or U-shaped rooms.

Has anyone already found a way to it in Dynamo (a little bit as described here in the mapbox blog https://blog.mapbox.com/a-new-algorithm-for-finding-a-visual-center-of-a-polygon-7c77e6492fbc

Thank you

Hi @amadeumagalhaes

Is this what you need?

Hi @Kulkul

I’m looking for the visual center and not the centroid…
It would be something like this…

I just found some documentation on a “inner centroid”

And more notably information on SHAPELY, a BSD-licensed Python package for manipulation and analysis of planar geometric objects.

I’m a noob in Python but anyone thinks that it would be possible to use their object.representative_point in dynamo ?

https://shapely.readthedocs.io/en/latest/manual.html#object.representative_point

Thanks !!!

Hi Amadeu,

Indeed, the centroids can be outside the polygon:

But the Polylabel algorithm can be used with Revit :


And it’s a good way to tag items :

18 Likes

Merci @Alban_de_Chasteigner !!!

Sincere thanks Alban your posts helps me a lot in many situations :ok_hand:

1 Like

Hello @Alban_de_Chasteigner. I have tried using the Element Inner Centroid but am getting nothing but null values

In the screenshot I am using Solids but have also tried this with just the room elements and still nothing.

Hi,

A solid isn’t a Revit element so it can’t work.
Make sure you are using an updated version of the Genius Loci package.
Show the entire graph with the rooms connected to the Element Inner Centroid node.

1 Like

I have used some other nodes to get some test data for now but would like to replace some of the nodes with the centroid node from Genius Loci. I have downloaded the latest version from the package manager. Open to suggestions on how I can fix this so that the centroid node works.

Hi Paul…dont think you feed in element…as Alban mention…

Hi Sovitek. I apologize my drawing earlier appeared to be incorrect. I did connect the nodes as suggested and still only get null values. See image below:

No worries…do you had unplaced rooms…if yes filter them first…

There are some rooms that have issues with element.geometry I think because of how a polyline or something to that effect was done. I do filter the empty lists out later in the script (see the python block) but in the list from the list.filterbyboolmask there are no unassigned rooms. I simply am filtering out rooms that do not belong to the level I am interested in.

1 Like

hmm…try to keep you list flattern before you feed into element centroid…

The list ouf of filterbyboolmask is flattened but just in case I did run it through a list.flatten and still no change

Think you had some not valid rooms…try to filter them out first, what happens if you only feed in one room, you know is valid ?

@sovitek I did make a python block to only push one room into the centroid node and it did work. I also tried index 57 which is the first room that has an issue with element.geometry and the null value returned. Looks like you were correct in terms of filtering out rooms that end up having issues with element.geometry. Oddly enough element 57 does have an area so I can’t filter by area property.

Any suggestions on how to filter out index values that have empty lists using element.geometry?

Hi @Paul_Vandenberk …you could try remove/replace at index or something…but in my opnion the best will be to look at these rooms inside revit check boundery etc… and fix it