# View.draw\_points question

**URL:** <https://forums.sketchup.com/t/view-draw-points-question/202382>\
**Category:** Ruby API\
**Created:** [July 1, 2022, 10:47am UTC](https://forums.sketchup.com/t/view-draw-points-question/202382 "2022-07-01T10:47:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeeWee](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@PeeWee](https://forums.sketchup.com/u/PeeWee)\
**Post date:** [July 1, 2022, 10:47am UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/1 "2022-07-01T10:47:49Z")

</div>

In an extension, i am using view.draw\_points to draw the corner points of several components. When i execute the draw, all points are drawn and all points are also visible, even when there is other geometry in front of it. Is there a way, to display only the points that are not behind other geometry, as you’d expect if you’d draw 'm as seperate cpoints for instance?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [July 1, 2022, 11:22am UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/2 "2022-07-01T11:22:19Z")

</div>

Hard to tell what’s going on without sample code and model. (Screenshots would help as well.)

---

<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:** [July 1, 2022, 12:05pm UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/3 "2022-07-01T12:05:35Z")

</div>

You have a collection of potential points.  
In turn project a ray from each one towards the camera eye point.  
If it doesn’t return a ‘hit’ then display the point, if it hits something don’t display it…

---

<div class="post-metadata">

**Author:** ![dezmo](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/dezmo/32/51058_2.png) [@dezmo](https://forums.sketchup.com/u/dezmo)\
**Post date:** [July 1, 2022, 12:12pm UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/4 "2022-07-01T12:12:12Z")

</div>

I guess you mentioning that the  
[# **draw\_points** (points, size = 6, style = 3, color = ‘black’) ⇒ Sketchup::View](https://ruby.sketchup.com/Sketchup/View.html#draw_points-instance_method)

method is used to draw points which is behave similar to the [#draw2d](https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method) method witch is used to draw in screen space instead of 3D space. So all points drawn with .`draw_points` method is always visible, regardless if there is a geometry “in front of it”.

* * *

You need to use the [#draw](https://ruby.sketchup.com/Sketchup/View.html#draw-instance_method) method, and “mimic” the point style (actually write your own method) using the appropriate OpenGL terms (e.g. GL\_LINES, GL\_POLYGON…ect.)

I find my old study about “fancy” points… you may use as a base:  
[https://forums.sketchup.com/t/draw-ugly-points-draw-fancy-point-if-on-mouse-not-move-study/89464](https://forums.sketchup.com/t/draw-ugly-points-draw-fancy-point-if-on-mouse-not-move-study/89464)

---

<div class="post-metadata">

**Author:** ![PeeWee](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@PeeWee](https://forums.sketchup.com/u/PeeWee)\
**Post date:** [July 1, 2022, 1:16pm UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/5 "2022-07-01T13:16:26Z")

</div>

Thanks for your reply. I was looking for a default solution or setting maybe, but if writing it myself is the only way, then thats what needs to be done 🙂  
Thanks for the study, ill definitly check it.

---

<div class="post-metadata">

**Author:** ![PeeWee](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@PeeWee](https://forums.sketchup.com/u/PeeWee)\
**Post date:** [July 4, 2022, 11:16am UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/6 "2022-07-04T11:16:33Z")

</div>

Ill fiddle around with it, but any input is welcome. This is my issue. In the screenshot, i show al corners of all components using:

view.draw\_points(points, size, style, color)

As you can see the blue circeled points are behind other geometry and i dont want to display those. I only want to display the visible ones, preferably without having to code that all myself…  
.

 ![draw_points](https://global.discourse-cdn.com/sketchup/original/3X/b/d/bd5518a4011609b238dbf7ca9aae83514c44102b.png)

---

<div class="post-metadata">

**Author:** ![PeeWee](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@PeeWee](https://forums.sketchup.com/u/PeeWee)\
**Post date:** [July 6, 2022, 12:30pm UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/7 "2022-07-06T12:30:11Z")

</div>

Little extra question :  
you say : " method is used to draw points which is behave similar to the [#draw2d](https://ruby.sketchup.com/Sketchup/View.html#draw2d-instance_method) method witch is used to draw in screen space instead of 3D space. So all points drawn with .`draw_points` method is always visible, regardless if there is a geometry “in front of it”."

I wonder why draw\_lines on the view does hide lines that are behind other geometry, seems similar routine to me but the behaviour is different

---

<div class="post-metadata">

**Author:** ![dezmo](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/dezmo/32/51058_2.png) [@dezmo](https://forums.sketchup.com/u/dezmo)\
**Post date:** [July 6, 2022, 12:43pm UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/8 "2022-07-06T12:43:31Z")

</div>

Good question. I have no answer.

---

<div class="post-metadata">

**Author:** ![slbaumgartner](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/slbaumgartner/32/7302_2.png) [@slbaumgartner](https://forums.sketchup.com/u/slbaumgartner)\
**Post date:** [July 6, 2022, 1:18pm UTC](https://forums.sketchup.com/t/view-draw-points-question/202382/9 "2022-07-06T13:18:23Z")

</div>

The answer is probably lost in history, as these methods date back to SketchUp 6.0. Who knows what the developers were thinking at that time?
