# Are the position of the clipping planes known to the API?

**URL:** <https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473>\
**Category:** Ruby API\
**Tags:** tools, window, selection\
**Created:** [March 21, 2020, 1:07pm UTC](https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473 "2020-03-21T13:07:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CAUL](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@CAUL](https://forums.sketchup.com/u/CAUL)\
**Post date:** [March 21, 2020, 1:07pm UTC](https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473/1 "2020-03-21T13:07:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![TIG](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tig/32/198_2.png) [@TIG](https://forums.sketchup.com/u/TIG)\
**Post date:** [March 21, 2020, 3:03pm UTC](https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473/2 "2020-03-21T15:03:49Z")

</div>

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:

```ruby
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.  
[Class: Sketchup::Tool — SketchUp Ruby API Documentation](https://ruby.sketchup.com/Sketchup/Tool.html#getExtents-instance_method)

---

<div class="post-metadata">

**Author:** ![CAUL](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@CAUL](https://forums.sketchup.com/u/CAUL)\
**Post date:** [March 21, 2020, 3:18pm UTC](https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473/3 "2020-03-21T15:18:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [March 21, 2020, 3:47pm UTC](https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473/4 "2020-03-21T15:47:42Z")

</div>

> [@CAUL](#):
>
> 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.

Actually area (box) selection support **has** been added to the API.  
It is implemented in the [`Sketchup::PickHelper`](https://ruby.sketchup.com/Sketchup/PickHelper.html) class.

- [`Sketchup::PickHelper#boundingbox_pick()`](https://ruby.sketchup.com/Sketchup/PickHelper.html#boundingbox_pick-instance_method)

- [`Sketchup::PickHelper#window_pick()`](https://ruby.sketchup.com/Sketchup/PickHelper.html#window_pick-instance_method)

---

<div class="post-metadata">

**Author:** ![CAUL](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@CAUL](https://forums.sketchup.com/u/CAUL)\
**Post date:** [March 21, 2020, 3:54pm UTC](https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473/5 "2020-03-21T15:54:32Z")

</div>

Exactly what’s needed. Thank you! I have to start reading the documentation more carefully.

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [March 21, 2020, 3:59pm UTC](https://forums.sketchup.com/t/are-the-position-of-the-clipping-planes-known-to-the-api/119473/6 "2020-03-21T15:59:55Z")

</div>

Okay, but do not dismiss what TIG said …

> [@CAUL](#):
>
> There are no points to be inferred …

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 `draw` methods.

If you do not implement a [`getExtents()`](https://ruby.sketchup.com/Sketchup/Tool.html#getExtents-instance_method) 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.)
