How to show a Preview of the line to the user without actually drawing it

Hi, I’m sorry if this might seem a bit primitive, but I am new to using the Ruby API. I want to be able to show the user a preview of where the object is going to be placed. To do so, after the user clicks anywhere on the screen, I use the Sketchup.active_model.entities.add_line pts, pte to draw a line showing where the object is going to be on the mouse move event.

Everything works for me so far, the one issue that I have is that each line that I am drawing is written to history. So after I am done drawing the object, if I want to undo what I had just done, I would have to keep undoing also for all of the mouse move events for which I drew a line.

So my question is: is there any way to draw a line on the screen on the mouse move event for giving the user a preview, without it being recorded in the history. Or in other words, is there a way to show a line to the user, without actually drawing it?

Look at the draw method of Tool protocol and also the various view draw methods you will call from there,


You are great!!! Thank you so much