Notice that what you draw on the screen lives only until the screen is redrawn with the next frame (camera or anything else changed). That’s why only tools have control over drawing to the viewport (mentioned in the intro of View). A tool is like the line tool and the push pull tool: only one of them can be active.
A minimal tool to draw on the viewport:
class MyTool
def draw(view) # SketchUp calls the method when a redraw is required, and gives it the view to draw to.
point16 = Geom::Point3d.new(0, 0, 0)
status = view.draw_text(point16, "This is a test")
rescue Exception => e # Tool methods are invoked dispatched from the Ruby Console / Ruby loading, so exceptions wouldn't go to the console but stay silent and unnoticed.
puts e.message
puts e.backtrace
end
end
Learn more about tools here:
API Documentation: Tool class
Official LineTool example
Forum example for a tool
The SketchUcation topic mentions that the text color is a model setting (currently). It does however not suggest to modify the model setting, because that would not only upset your plugin users, but also add infinite operations to the undo stack, and trigger a viewport refresh, causing an infinite loop.