rosti Posted February 25, 2017 Share Posted February 25, 2017 (edited) I would like to know the largest orthogonal rectangle to fit within any handled polygon or polyline. Within that one might fit a textblock or other. Could I script this using VectorScript? Edited February 25, 2017 by rosti Quote Link to comment
DomC Posted February 25, 2017 Share Posted February 25, 2017 Can an Vectorscript solve this problem? The answer is yes. If you ask for a Vectorscript function for that: The answer is no. And the task is not really clear. You want to find the widest rectangle with the height x? Or you want the have the rectangle with the largest area? Or the widest Rectangle which height is minimum 20% (or some kind like this) of the width? I think the simplest way would be, to make a grid over your polygon. Then you have rows and columns. With that, you could generate the biggest, the widest and the highest recangle. Not sure, but I think this could be a possible approach. I would do that with python script. There seems to be solutions available on the net. As example here: https://gist.github.com/zed/776423 This code for that looks quite simple. Maybe that script has to be adjusted. As example store the start endpoint of the rectangle inside the script. At the moment this just returns max area, width and height not the position. Interesting and useful task ... Quote Link to comment
rosti Posted February 25, 2017 Author Share Posted February 25, 2017 (edited) Thank you for replying, Nice image too. I had a look at the python script, and it might take me in between a day or maybe a year to understand. I will try, but I don't know when I can react on that. I assume there are matrix-steps add by each loop until a border is hit somewhere. Is that how a program like Vectorworks renders the fills of polys on screen? As a routine for a task like this could serve many cases, I tried not to be that clear. In my case I was thinking of a way to find the ideal location of a generated text informing about different rooms or spaces. If you want the text to be as large as possible, in a circle or square you might locate it at its center. If you think of a L-shaped room or curved space, the ideal location, could be found by the eye, but to calculate it might be harder. So for instance for the L-shaped room, using the eye, you would opt between 2 rectangles, and pick the largest and maybe rotate the text 90 degrees. In case of your image you might opt for the red one. Looking at the image, I would say as next step could be to compare some initial ratio of the text, by knowing its content, and try to fit such a rectangle best. So: Say a rectangle like the green one might have the best ratio, then have the actual text object centered at that green rectangles midpoint. After that size of the green rectangle and the text block might reduce the font size, to have it fit, or if the font would get to small to read, you have to, still, move it outside the area by using a pointing device of choise. Maybe someone might want to place a symbol within the room. Maybe there might be a hole in the room, or worse. Edited February 27, 2017 by rosti Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.