Dear Friends,
In following code example, we create a group (grp) also we consider 2 points (ref_pt1 and ref_pt2). Both points are on face1 and face2 is in opposite side of face1. How can we know line perpendicular to the face1 at ref_pt1 and ref_pt2 pass through face2? It seems raytest cannot help me for it or I don’t know how to use it.
grp = Sketchup.active_model.active_entities.add_group
pt0 = [0, 0, 0]
pt1 = [2, 10, 0]
pt2 = [8, 10, 0]
pt3 = [10, 0, 0]
face = grp.entities.add_face pt0, pt1, pt2, pt3
face.pushpull -10
######
ref_pt1 = [1, 0, 5]
ref_pt2 = [5, 0, 5]
face1 = nil
face2 = nil
grp.entities.grep(Sketchup::Face) do |f|
result = f.classify_point(ref_pt1)
face1 = f if result == Sketchup::Face::PointInside
end
face1.material = "Green"
grp.entities.grep(Sketchup::Face) do |f|
face2 = f if f.normal.reverse == face1.normal
end
face2.material = "red"
Read about “virtual” lines in the Geom module Overview section.
Then you will use the ref pts as the point to construct a line array, and you will probably use the reverse of the face’s normal vector for the line vector. (But it really does not matter which direction the vector points, as virtual lines are infinite in length in both directions.)