I have a pattern already generated in g-code form, like in the following sketch. There are a lot of small lines along the path, only G1.
(There is also intricate Z movement, if somebody thinks why such a complicated approach to a simple task.)
Basically I want to be able to eliminate all the g-code lines that have the XY position outside a given shape.