Are you implying that the user may want only Current Space & then there would be a bad result?
create a layout "layout1"
draw a polyline there
create another layout "layout2"
and draw a polyline there
now activate "Model"
run your code and note the result
now activate "layout1" and then activate back "Model"
run your code and see that results are different (at least it is so in acad 2005)
this is all because of the specific bahavior of (entnext) which steps through model first and then through last active layout.
ssget does a like error
we should both add some kind of (= (getvar "CTAB") (cdr (assoc 410 ....