Snap to inference points in custom tool

Hi All,
I have written a custom tool similar to line tool (BaselineTool).

class BaselineTool
  def activate
    $ents = Sketchup.active_model.entities
    @pt1 = Sketchup::InputPoint.new
    @org = Sketchup::InputPoint.new
  end
  def onMouseMove(flags, x, y, view)
    @pt1.pick(view, x, y, @org)
    view.tooltip = @pt1.tooltip 
    view.invalidate
  end
  def onLButtonDown flags, x, y, view
    draw_baseline
  end
  CURSOR_PENCIL = 632
  def onSetCursor
        UI.set_cursor(CURSOR_PENCIL)
  end
  def draw_baseline
    line = $ents.add_line @pt1.position, [0,0,0]
    puts @pt1.position
  end
end

baseline_cmd = UI::Command.new("Baseline") {
Sketchup.active_model.select_tool BaselineTool.new
}
baseline_cmd.small_icon = "baseline.png"
baseline_cmd.large_icon = "baseline.png"
baseline_cmd.tooltip = "Create a Baseline"
baseline_toolbar = UI::Toolbar.new "Baseline"
baseline_toolbar.add_item baseline_cmd
baseline_toolbar.show

When you select this tool, wherever you click, it creates a line from that point to origin [0,0,0]. it works but the problem is I cannot see inference points in the model to click on. I managed to add tooltips to show inference points as you can see below but I want to have colored inference points to select the points precisely.


Can I have your comments please?

Have you read the line tool example in the Examples repository ?
(It is called 02_custom_tool. If you read the edition beneath the “Tutorials” section, it has much more comments to help new coders.)

Whoops .. wrong method ...

I believe you need to get the InputPoint from the view.
See method …

Sketchup::View#inputpoint

The correct method is Sketchup::InputPoint#draw.

You need to tell the inputpoint to draw. From the example …

      def draw(view)
        draw_preview(view)
        @mouse_ip.draw(view) if @mouse_ip.display?
      end

You may not realize, but the #draw callback is a special callback method that the SketchUp engine expects tool classes to implement.

In the above example method you would change the draw_preview(view) call to your draw_baseline() method, and of course the variable identifiers for the inputpoint need to change to what your code is using.