Is it possible to restrict lines on the ground when drawing?

When drawing lines, is it possible to make all lines on the ground when moving my mouse to draw them?

Yes. Depends on what you want to achieve.
For example you can use the Point3D #project_to_plane method to retrieve the point on a plane that is closest to the cursor ( e.g. the InputPoint ) position .

Or check the code of e.g. TIG’s 2D Tools.