And how to make the selection set for both model and paper space in the same routine?
Ex.: How to select all hacths in model and paper space?
You can make a selection set [in AutoLISP terms] of all Hatch patterns in model and paper space easily enough, with:
(ssget "_X" '((0 . "HATCH")))
But you can't have an AutoCAD command "select" and do something with those that are not in the current space. [See the hatch-to-back thread for a workaround, unless you're asking this for some different reason.]
Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.