How to trace a virtual line from one point to the first object it meets

Hello, I have an object and I already detected its corners coordinates. And I need from one of the lowest corner to trace a virtual line until I get to the floor, in my case it will be a face from an entity collection.
Here are some screens, hope it helps to understand me:

So I need somehow to determine coordinates of that floor or just the distance from corner to first entity it collides if we go down on Z-axis. How it could be done, can someone help me to understand?)
Thanks in advance!


Does not tested, just an idea:

model = Sketchup.active_model
point = detected_corners_coordinates
virtual_line = Z_AXIS.reverse
face =  will_be_a_face_from_an_entity_collection
ray = [ point, virtual_line ]
item = model.raytest(ray, true)                                
if item && item[1].last == face
  determined_coordinates_of_that_floor = item[0]
  just_the_distance = point.discance determined_coordinates_of_that_floor 

Insteed of
if item && item[1].last == face
could be used:
if item && item[1].include?(face)

1 Like

Read the SketchUp tutorial on Guides (guidelines). I use a guide as a “virtual” line for what you’re wanting to do.
Guides are not actual lines; they display as dashed lines. When a guide hits an entity it creates an intersection that is findable.
There numerous ways to use it; think of guides as reference lines. You draw the guide, then measure it’s length.
Definetly read the SketchUp help page for Guides.

It will work if you do it manually. This topic is in [Developers] [Ruby API] category. :wink:

Thank you, I modified it a bit for my needs and this approach worked!

1 Like