Detecting/selecting a temporary Drawing
-
I want to make a sketchup tool.. I wanted it to select a temporary drawing like it will change color when I select or hover my mouse on it ..
can anyone give me a head start on how to do itI have done a lot of google search but i just cant seem to pin point what kind of term fits it
what i need is :
1.) to detect and change the color of the temporary drawing square in the "def draw" everytime i hover and select it
2.) to detect and change the color of the temporary corner of the square in the "def draw " everytime i hover and select itplease examine my code below
class MyTool
def initialize end def activate @mouse_ip = Sketchup::InputPoint.new @picked_first_ip = Sketchup::InputPoint.new end def draw(view) @mouse_ip.draw(view) if @mouse_ip.display? # Draw a square.
points = [
Geom::Point3d.new(0, 0, 0),
Geom::Point3d.new(9, 0, 0),
Geom::Point3d.new(9, 9, 0),
Geom::Point3d.new(0, 9, 0)
]Fill
view.drawing_color = Sketchup::Color.new(255, 128, 128)
view.draw(GL_QUADS, points)Outline
view.line_stipple = '' # Solid line
view.drawing_color = Sketchup::Color.new(64, 0, 0)
view.draw(GL_LINE_LOOP, points)end def onLButtonDown(flags,x,y,view) puts "yout tool has clicked" end def onLButtonUp(flags,x,y,view) puts "yout tool has clicked" puts end def onMouseMove(flags, x, y, view) if picked_first_point? @mouse_ip.pick(view, x, y, @picked_first_ip) puts "point A" else @mouse_ip.pick(view, x, y) end if @mouse_ip.valid? view.tooltip = @mouse_ip.tooltip end starting_point = Geom::Point3d.new(9, 0, 0) ip2 = Sketchup::InputPoint.new(starting_point) view.inputPoint(x,y,ip2) view.invalidate end def picked_first_point? @picked_first_ip.valid? end def getBoundingBox(corner) model= Sketchup.active_model selection = model.selection return selection[0].bounds.corner(corner) end def resume(view) view.refresh end
end
my_tool = MyTool.new
Sketchup.active_model.select_tool(my_tool)
-
No one will attempt to even read you code until it is properly formatted within
[ code ]
...[ /code ]
tags.There is a button on the post edit toolbar to insert these tag sets, or highlight a bunch of text and click the button to wrap the text in these tags.
Advertisement