@dani-perez wrote:
.... I have a random field and I have to draw the shortest path, going over the full area (closed pline). .....
If by that you mean that the red path in your sample drawing should be running in the direction that results in its being the shortest total length possible, then I think the main direction of its "passes" would need to be parallel to the longer direction of the "field" shape. All the stepping-over ends of the back and forth are "wasted" length, so you want as few of them as possible, which is why the main length direction of the path should be the same as the main length direction of the field.
To find what that main length direction is, you can use SmallestRectangle.lsp, with its SR command, available >here<. Applied to your sample field shape, it gives this result [yellow]:

Coincidentally, that happens to be exactly an orthogonal rectangle, but the routine works in whole-1-degree increments, so it could be that being rotated a quarter of a degree or something could be slightly more precisely the smallest rectangle, though that difference wouldn't make much difference to a path's overall length.
Does that look like a good starting point? It obviously needs further development to get to what you want, but I think it will find the most length-efficient direction for the path to run its long segments.
Kent Cooper, AIA