When creating sheets, we need to create a coordinate grid with coordinate labels for the plan layouts. I am hoping to automate this process, but I am getting stuck at the label placement and formatting.
I will quickly explain the workflow developed to date
- A polygon is selected
- The bounding box min and max coordinates are extracted, maximum coordinate is rounded up to the nearest 100 and minimum coordinate is rounded down to the nearest 100.
- Lines in the X and Y direction is created from the minimum to maximum value at a step specified
- A geometry intersect is the used to create points where the lines cross the polygon
- And finally, these points as connected to create the grid lines.
Since the text needs to be inside the polygon, the rotation will depend on the location, my idea was to create the labels in groups based on the start or the end of the line and set the rotation accordingly, like the sketch.
but for some reason… the start coordinate switches…and creates the labels like this
Is there maybe a way to move text along a line until it is inside a polygon? or some other way to achieve this?
Then, I would also like to make the mtext annotative and have background mask… but it doesn’t seem like there are nodes for this.
I attach the script and an example drawing.
GEN_Create grid on Polyline_2024.dyn (159.4 KB)
Grid_test.dwg (6.9 MB)