Ah, too bad. Of course I want a custom move tool and rectangle tool as well. I do have a line tool working with inference locking and and the VCB activated.
well, for future, I'll post my line tool:
class Custom_Line
def initialize
@cursor = UI.create_cursor("Cursor.tiff",1,1)
end # def initialize
def activate
$ip = Sketchup::InputPoint.new
Sketchup.active_model.selection.clear
@ip1 = nil
end
def onSetCursor
UI.set_cursor(@cursor)
end
def onMouseMove(flags, x, y, view)
$ip.pick(view, x, y)
view.invalidate
end
def draw(view)
$ip.draw(view)
if(@pt1 == nil)
view = view.draw_line $ip.position, $ip.position
else
Sketchup.vcb_label = @pt1.distance($ip.position).to_s
view = view.draw_line @pt1, $ip.position #draws line from last point to current position
view.invalidate
end
end
def onKeyUp(key, repeat, flags, view)
if(key==16)
view.lock_inference
end
end
def enableVCB?
return true
end
def onUserText(text, view)
begin
if(@pt1 != nil)
value = text.to_l # convert the value to a length
point2 = [$ip.position]
dist = @pt1.distance(point2)
w2 = value/dist
w1 = 1-w2
@pt2 = Geom::Point3d.linear_combination w1, @pt1, w2, point2
line = Sketchup.active_model.entities.add_edges @pt1, @pt2 # RIGHT NOW, JUST ADDS TO THE BASE LEVEL
line[0].set_attribute "EPdict", "Tool", "Node/Branch"
@pt1 = @pt2
Sketchup.vcb_value = ''
end
rescue
# Error parsing the text
UI.beep
value = nil
end
end
def onKeyDown(key, repeat, flags, view)
if(key==16&&@pt1!=nil)
ip1 = Sketchup::InputPoint.new(@pt1)
@pt2 = $ip.position
ip2 = Sketchup::InputPoint.new(@pt2)
view.lock_inference(ip1,ip2)
end
end
def onLButtonUp(flags, x, y, view)
if(@pt1 == nil)
@pt1 = [$ip.position]
else
@pt2 = [$ip.position]
line = Sketchup.active_model.entities.add_edges @pt1, @pt2 # RIGHT NOW, JUST ADDS TO THE BASE LEVEL
@pt1 = @pt2
Sketchup.active_model.active_view.invalidate
end # if state
end
end