Hi everyone! First time posting, so please let me know if I missed any important information!
I'm currently working on creating facade models for a project and I'm really stuck on how to get the smallest areas of a building level. My goal is to use the smallest areas to decide whether or not to split them for window tiles (I'm importing custom-made models that only fit within a certain area).
I saw this thread "Find the face with the largest area" and got some results using the code:
sizes = comp(f){ all : geometry.area() }
indices = sortIndices(sizes)
largestIndex = indices[size(indices)-1]
^ This is written outside of StartRule and in my subdivided ground floor the code looks like this:
GroundLevel -->
comp(f) { side = comp(f) { largestIndex : color(1,0,1) fa. } }
print(sizes)
As you can see, I tried to print out the array to check what areas exist and got:
[672.235005617142,672.235005617142,56.9623955950849,65.0227577575442,0.651960614471675,0.653950613834463,27.0863178546652,0.651960614471657,91.997532132469,0.651960614471657,30.1915471392886,37.9559232293518,0.639519132401011,88.6085877364206,0.602389473175416,26.3556398606954,0.59927572603669,19.7058619671217,0.651960614471675,0.605893140155699,61.1657785006099,25.1026779969368,6.14195367158903,7.84706793669057,1.498212563952,10.0207031040625,1.49847461706181,7.86142905982004,6.15483418270743,33.4894580774452,2.29956137631535,23.1626854369825,2.2989816671091,6.45603386387014,13.3447547574518,8.79932702753264,7.80603914136429,1.398090426035,10.0135336878099,1.39960999591291,7.84833177362034,6.27738294607007]
But I can't for the life of me figure out:
How to use reverse array from the documentation?
Why isn't the list sorted??
How to loop through the array and filter only the ones bigger than X square meters?
Note: I wanted to upload images, but I can't for some reason… (sorry!)
Welp ofc did the linking to the post not work so here we go again: Getting the smallest area with sorting array of geometry.area function
it's in the doc nonetheless:
reverse(array) = array[size(array)-1:-1:0]
sortAsc(array) = array[sortIndices(array)]
sortDesc(array) = reverse(sortAsc(array))
Example:
const a = ["a", "c", "b"]
const b = sortAsc(a) // [a,b,c]
const c = sortDesc(a) // [c,b,a]