@sdmitch said:
@lbsswu said:
Hi everyone,
Suppose I have opened the Sketchup software, I want to know whether a 3D point is visible or not in current view.
For example, the 3D point may locate on the back of a person, thus we can't see it when the person facing to us.This should be done by Sketchup ruby code.Could anyone help me?
I placed a construction point, the little black dot just below the horizon, and "Nancy" in the model. I then used the following code to test if the point was visible.
mod = Sketchup.active_model
> ent = mod.active_entities
> sel = mod.selection
> vue = mod.active_view
> eye = vue.camera.eye
> cp = ent.grep(Sketchup;;ConstructionPoint)[0]
> pt = cp.position
> vec = pt.vector_to(eye)
> hit = mod.raytest([pt,vec])
> if hit
> puts "pt is not visible"
> else
> puts "pt is visible"
> end
>
Hi, sdmitch. Thank you very much. It works!