1.
Q: How to make Hatch via script?
A: Same way as not-via-Script (but via commandline)
For example: Some autocad object selection-methods or drawing commands are view depend (nothing to do with scripts),
so you make sure that the view is well, do the the same in your script.
2.
It is useless to call international commands when the following options are inserted local
Use italian commands+options, or much better: use international commands AND OPTIONS.
3.
In your script are situation of point or object selection and you don't handle the snap mode
Add object snap inputs to your script or manage the osnapcoord value.
4.
back to your problem: We can not see your problem in detail without your file (you didn't start with a blank file, right?)
Please upload a sample file, because we don't know about your rectangles.
Upload 1 file "before" and one hand modified file "after", so we can see exactly what you try to do.
General: You know where the rectangles are, so you can ZOOM to the point of selection and
also to zoom out to the bounding area of all needed objects for hatching.
5.
Forget the # hint in case of scripts, scripts feeding the commandline, not the dynamic input interface
and in commandline # is useless (or?).
_
International
Use local or international calls, there is no reason to mix.
Command and options, start with an underline, following by the english command/option =>
-TRATTEGGIO | Seleziona oggetti
-hatch | Select objects
In your script is just a "S" as option, it will work for english and italien version, but in germany for example not
Schraffur | objekt Auswählen
Use _hatch _s will work in "all" language versions.
The Point. A POINT ion front of commands force the program to use the native command,
use it to make sure you control the native command.
(3parts can edit the command behind the command call, the point forces acad to use the native command)
current: _HATCH s
better: -TRATTEGGIO s
much better: _HATCH _s
best of: _.HATCH _s (if you want to use the native command)