Where's My Inference Dots?
-
Shouldn't this produce inference dots? It's only a slightly modified linetool.rb.
require 'sketchup' class JimTool def activate @ip = Sketchup;;InputPoint.new @ip1 = Sketchup;;InputPoint.new end def onMouseMove(flags, x, y, view) @ip.pick(view, x, y) if @ip != @ip1 view.invalidate if @ip.display? or @ip1.display? @ip1.copy!(@ip) view.tooltip = @ip1.tooltip end end end Sketchup.active_model.select_tool(JimTool.new)
-
No, you're not drawing anything - so nothing should appear. Are you getting inference dots?
-
I see, you want to draw the inference points. You must call the
.draw
method for theInputPoint
in theTool
'sdraw
event.require 'sketchup' class JimTool def activate @ip = Sketchup;;InputPoint.new @ip1 = Sketchup;;InputPoint.new end def onMouseMove(flags, x, y, view) @ip.pick(view, x, y) if @ip != @ip1 view.invalidate if @ip.display? or @ip1.display? @ip1.copy!(@ip) view.tooltip = @ip1.tooltip end end def draw(view) @ip1.draw if @ip1.valid? end end Sketchup.active_model.select_tool(JimTool.new)
-
Thank you. I just wish the answer wasn't so obvious!
/me smacks forehead.
-
I'm not sure if you need to use two InputPoints...
The Docs says that thepick
method returnstrue
only if the picked entity is different from the last pick. So I'd think it should be enough to just use the one and invalidate only whenpick
returnstrue
. Think I'm doing this with my current tool I'm working on. -
I could be way off, but I was thinking it was an optimization thing. I think they are just checking to see if the inputpoint changed, and only if it changes do they refire the draw method. Otherwise each pixel move of the mouse creates a new IP point, and therefore refires the draw method with each pixel movement, even if the IPpoint is already drawn. So testing to see if its a new point will make it only redraw it each time there is a new point to draw. Not each pixel the mouse moves. Again, that is untested recently but that has been my understanding of the example they provide.
Chris
-
@chris fullmer said:
I could be way off, but I was thinking it was an optimization thing. I think they are just checking to see if the inputpoint changed, and only if it changes do they refire the draw method.
ChrisBut as the manual says:
@unknownuser said:
true if a valid InputPoint was picked and it is different than it was before.
From that, it sounds like the
InputPoint
object is performing the check for you. It returnstrue
only if it's different from the last time you calledpick
.]
(Note: I haven't tested that the implementation actually works as the manual says it should. We have enough examples of deviance...)
Advertisement