I want to implement an area select within a tool. For this to work we need to know the distances of the clipping planes. Are these known to the API?
If the points you are inferring are beyond the current model’s bounds the temporary graphics etc can become clipped.
Dynamically set the model.bounds in your Tool class using the getExtents method - something like:
def getExtents bbox = Sketchup.active_model.bounds bbox.add(@ip.position) if @ip && @ip.valid? bbox.add(@ip1.position) if @ip1 && @ip1.valid? bbox.add(@ip2.position) if @ip2 && @ip2.valid? bbox.add(@ip3.position) if @ip3 && @ip3.valid? return bbox end
The number of @ip… InputPoints used for getting the position [points] to add to the bounds depends on your own tool’s function - in the example above the 4 points are used, but you might have fewer or even more.
There are no points to be inferred since I’m implementing an area select. An area select is just a rectangle in screen space translating into a frustum in 3d-space starting at the near clipping plane. It does not seem like the API gives support for implementing an area select so the task of figuring out what’s inside the frustum has to be done in my code. However, in order to know what the frustum is I need the location of at least the near clipping plane.
Actually area (box) selection support has been added to the API.
It is implemented in the
Exactly what’s needed. Thank you! I have to start reading the documentation more carefully.
Okay, but do not dismiss what TIG said …
He meant the points you were referring to.
In order for your tool to draw the picking window on the screen, (like the native selection tool does,) your tool must make sure that the two corners (the points of the picking window) are added to the tool’s idea of what the display extents are.
As TIG explained, your tool tells the SketchUp engine what the display extents are via your tool’s
getExtents() callback method. The SketchUp engine will poll your tool object for this callback and if it exists, then the engine will call this method before executing any of your tool’s
If you do not implement a
getExtents() callback method properly, either nothing in your draw methods will be seen, or some of it might be clipped. (ADD: I think the documentation implies that the default is the model’s bounds used as the display extents, if your tool does not implement this callback.)