Anyone know what's wrong with the linetool example?
-
I'm pretty new at this, sorry. I've been looking at the linetool.rb script that comes with SU, and I'm having trouble with it. When the tool is in the "picking second point" state, and its draw method is being called, the line that's drawn between the first point and the current mouse location is not always "complete". That is, the line extends from the first point to a point in between the first point and my mouse and stops. When I click to select the second point, the construction line that the tool is supposed to draw works fine. It's only the temporary graphics in between selecting the first and second point. I modified the draw method to use view.draw_points to draw the first point and the point where the mouse is currently, and the points show up in the right place. Am I missing something? What is wrong with this example?
The point just floating out there is where my mouse pointer was when I took the screenshot.
-
Hi iceman,
I think the problem is that the linetool does not implement the 'getExtents' method. If you add this method to the tool, and make sure that it returns a bounding box that includes the position of BOTH inputpoints, then the tool should draw the preview line as expected.
http://groups.google.com/group/SketchUp-Plugins-Dev/web/Ruby-Tool.html#getExtents
This should work:
def getExtents bounds=Sketchup.active_model.bounds bounds.add(@ip.position) #add the input point position to the bounding box return bounds end
-
Thanks, Whaat. That did the trick. So the reason behind this is that SU was only invalidating a default area of the screen around the first point because I didn't implement getExtents?
Advertisement