2 messages in com.googlegroups.sketchuprubyNeed help on better way to do mouse s...
FromSent OnAttachments
Oscar Lok24 May 2007 22:47 
Oscar Lok26 May 2007 00:11 
Subject:Need help on better way to do mouse select
From:Oscar Lok (osca@sabah.net.my)
Date:05/24/2007 10:47:28 PM
List:com.googlegroups.sketchupruby

Hi,

I have write the below ruby, but I think there are better way to do this. Could anybody tell me how to make it like we select the dimension tool, please? It is like we move the mouse near the end or mid point of an edge, it will have an indicator appear.

def onLButtonDown(flags, x, y, view) @ip.pick(view,x,y) if @mode1 @end_pt = @ip.position constline = Sketchup.active_model.entities.add_cline (@start_pt,@end_pt) @mode1 = false else @mode1 = true @start_pt =...@ip.position end end

def onMouseMove(flags,x,y,view) if (@mode1) then if @constline @constline.erase! @t.erase! end @ip.pick(view,x,y) @pts = [@start_pt, @ip.position] @constline = Sketchup.active_model.entities.add_cline (@start_pt,@ip.position) @t = Sketchup.active_model.entities.add_text ((@constline.start).distance (@constline.end)).to_s, (@constline.end)

# I don't know how to use "view", the below cannot work.

# view.line_width = 10 # view.set_color_from_line(@pts[0], @pts[1]) # view.drawing_color = "gray" # view.draw(GL_LINES, @pts) # view.draw_lines($start_pt, $ip.position) end end

Thanks Oscar