SelVisible in Grasshopper?

Hi there !
Does anyone know if there is any way to implement “SelVisible” in grasshopper with Python?

I want to filter the geometries by the visibility (obscured by other geometries or not in a viewport).
I found the RhinoCommon API “Rhino.Display.RhinoVieport.IsVisible(point3d)”.
But it is not a function I want. It works only to detect whether a point is in a view frustum…
I want to distinguish or detect whether an object is hidden(obscred) by other objects in a specific viewport or in an active viewport.

Thank you so much for sharing your knowledge !

Its a bit of a hack, but you could use the command inside of Python:

import rhinoscriptsyntax as rs

#rs.VisibleObjects(None, True, False, False)

comm_str = "SelVisible " + " _Enter"

objs = rs.SelectedObjects()


I tested rs.VisibleObjects, but it only seems to filter objects outside of the view, not those hidden behind other objects.

1 Like

Thank you so much for your reply Adam!!

Question is the geometries I want to filter are GH Geometries.
So they are not in physically in rhino viewport. I want to avoid to bake geometries…
Please see the attached file…

Sorry my explanation was not sufficient…

I don’t know how i can, (10.1 KB)

I guess (without any reason,) that I have to use “Rhino.Display.ZBufferCapture”.
But I dont know how Rhino implements “SelVisible” internally…

I am making a scrit to calculate Building Shadow Lines.

this is literally the slowest and most wrong way to do it :slight_smile: (and it’s for R8, but I believe you can just swap a couple of View/Camera related components to make it work on R7)

retrieve camera of a given viewport (in this case Perspective), on the Target plane (which btw is NOT the very same size of the viewport but a bit smaller, so the sampling area is also smaller) build a grid of points, and use those points to create Vectors from Camera in such a way to cast isovist samples on whatever is on the screen and retrieve the index of the geometries that were hit (25.6 KB)

there’s a slider to change the resolution of the grid that generates the points on the camera Target plane: if you move it enough to the right it will fry your PC :slight_smile:

1 Like

Inno ! Thank you so much for your reply.
It is a very interesting approach ! It’s not wrong at all, actually I did a similar approach but yours is a more clever one. one thing to be concerned about is that your approach to use “Isovist” limits to filter points.
On the other hand “SelVisible” in Rhino seems faster…and it also filters points.

Anyway, until I find a better way I will refer to your scripts.
Thank you !

1 Like

I found this pretty old thread where something similar was done (in that case was sun rays)

the main point is that @PeterFotiadis C# script makes the whole computation so MUCH faster

Inno how you found That thread? Nice ! Thank you.

Actually In my script I already use “Rhino.Geometry.Ray3d” and “Rhino.Geometry.Intersect.Intersection.Rayshoot” to detect Shadow. Question is I want to make a hatch into shadow so that I need to detect which surface is visible from the Sun.
That is why I am looking for the “SelVisible” similar script.
It’s because my architecture model has thousands of geometries. so I need that kind of script which works fast like a selvisble command…

Thank you Inno

ok, I now maybe understand a bit more what you are trying to achieve

I have seen dozens of videos where people use Sunlight in Rhino to cast shadows, but then they usually render/export_viewport to further elaborate in Photoshop or any image editor

given a Camera and light, you are trying to get the 3D shape of the shadows cast by 3D shapes over other 3D shapes?

at the end are you going to make it into 2D views?

100% exact.
I have a script to make plan, section, elevation automatically wiht Make2d from 3D model.
And now I want to make shadow shapes.

All geometries needs to be curves or hatch to export to Autocad.

at the end are you going to make it into 2D views?

Yes! or even keeping 3d shapes with shadow for animation.