i have diffrent shapes that i want to label. but i want the text to be inside the shape.
1) method that i used
so my first thought was to use the area component but in many cases the centroid came outside the shape itself. hence that doesnt work. below you can see there are many points that are outside the shape.
2) 2nd method best result but very slow (need something faster) second method.gh (15.3 KB)
my next attempt was to populate the shape with points. this made everything run really slow cause i have around 1000s of shapes (but it had the best result)
3) 3rd method (just a little bit faster than the earlier method)
i first used dispatch to seperate the shapes that had holes in them. then i seperated the cnvex and the concave shapes.
for the concave shape i used the area component to find the center for the lable
for the convex shapes and the shapes that had holes in them i used the face boundary component to divide it into faces them found the centers of those faces and then found the center that was furthest away from the edges of the shape.
You might generate roofs by his scripts, explode them, extract Midpoint of highest edge and project it to XY plane.
In that manner you can somehow get closer to desired “centrish” position.
thats quite a nice solution.(jakinta)
the highest point found with this method should technically be the most centrish point inside the shape.
so while the other methods might fail in some cases to find the centermost point, this method should work in every case.
but the problem with this method is that it take quite a lot of time.
how did you get the name of the component above the component
is it the component on the left side (the one with the glasses on it)
what the name of the component ???
as for the solution i found that even after i find the centerish point on the shape there are some cases in which the text still goes out of the shape, because the text is simply large than the shape. or in some cases when the text is not oriented in the corrent way.
i think i will have to make a rectangle the size of the text and then move the recatngle on the centers of the mesh faces , and check if the rectangle is inside the shape. if the rectangle is outside the shape then i will have to rotate it or change its size.
but that will also take quite a lot of time to compute. so i think i will stick the mesh center method and make do with some text going out of the shape. (of maybe for places where the text is going out simply give it a symbol and mention the name in a legend or something)