View.draw_points question

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?

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

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…

3 Likes

I guess you mentioning that the
#draw_points(points, size = 6, style = 3, color = ‘black’) ⇒ Sketchup::View

method is used to draw points which is behave similar to the #draw2d 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 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

2 Likes

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 :slight_smile:
Thanks for the study, ill definitly check it.

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…
.

Little extra question :
you say : " method is used to draw points which is behave similar to the #draw2d 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

Good question. I have no answer.

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?

1 Like