I only want to select the closed polygons which are rectangles. I tried checking for number of segments but some of the curves have control points which are colinear, thus increasing the segment number. How should I approach this?
I would want them to be considered rectangles only. These are drafting errors that I do forsee happening by users of the script. @Baris idea to use discontinuities gives what I expect to consider a ‘rectangle’ even though it might not mean the actual geometric definition (90 degrees and equal adjacent sides)
Haha true true. Well this script is a small part of a much larger script for automating room labels in architecture plans. The kind of spaces my users will be dealing with right now will always resemble rectangles (even if they aren’t rectangles) so this will work for now.
Over the course of developing this script I have found that I don’t need to consider every possible edge case right at the beginning of developing a feature, because most of the times the edge cases are geometry related and the script will mostly always be operating on orthogonal geometries.
But thanks a lot, I have much more clarity on discontinuities now, and when something messes up I will know what it is!
are you playing the ok, now use your script with this data game?
The script was inteded for the provided test data and not for any possibly imanigable data.
I just checked, a lot of objects are far awya from the origin, which is never good. Maybe use the Similiarity module, which allows you to set a threshold. They are necessary anyway, if you have slightly off 90° angles and want to capture them.
Create a Bounding Box around each rectangle and check if the area of the rectangle matches the area of his corresponding Bounding Box. check if polyline is rectangle.gh (16.8 KB)
Looks like only the items 2 and 5 from your list are perfect square rectangles.
they also could be rotated, since BBox is aligned with the world coordinates.
Maybe creating a rectangle from 3 pts and check the area/Length could work.