Juncture plane of two touching Solid group

Hi all
I have 2 solid groups touching each other. So, how can I get that contact plane (juncture plane) with Ruby? Pls give me advice, thanks.

Their bounding boxes will intersect, and so will they.

Thanks for your reply, Dan. When using intersect method, everything (including juncture plane) was deleted and juncture plane was not kept as I expect. One more point, using intersect for bounding box of these 2 group, it seems that there is no change. So, please tell me if I need to do something to avoid this problem?

Post code correctly in the forum, not tiny images or video.

There are other boolean methods besides intersect.

I don’t know what you are doing as the video image is too small. But it works for me when the objects are aligned with the model axes. (This is the caveat with the BoundingBox method. Bounding boxes are always aligned with the model axes. This means that they can get bigger and no longer match the objects perimeter if the object is rotated.)

With two solid groups in the model alone …

g1, g2 = Sketchup.active_model.entities.to_a
bb = g1.bounds.intersect(g2.bounds)

#=> false

pts = []

# Use Array#include? to test point "sameness". It uses the member
# class' #== method for comparison (in this case Geom::Point3d#==
# that compares points within SketchUp's coordinate tolerance):

for i in 0..7
  pt = bb.corner(i)
  pts << pt if !pts.include?(pt)

Note: Array#uniq and Array#uniq! will not work here to remove
duplicates as they use Object#eql? and Object#hash, which always
produce different values for SketchUp Geom::Point3d objects, even
though they may be coincident points within SketchUp’s tolerance.

#=> 4
# pts is now an array of the 4 remaining corners of the
#  intersected bounding box (which is flat in this case.)

plane = Geom::fit_plane_to_points(pts)
#=> [1.0, -0.0, -0.0, -20.75]

But again the bounding box pattern would fail if either of the objects were rotated away from the model axes.

1 Like

Yes, sorry, well boolean operations are destructive.
To keep the objects you would need to do the boolean operation upon copies of the objects.

This subject has been covered in prior topics. Try searching this category on keywords … collision detection, interference, etc.

1 Like

Note that there is also Entities#intersect_with that may be non-destriuctive for your case.

1 Like

Thanks for your reply, Dan. I will get experience in posting code correctly in forum for the next time.
According to your advice, I got it successfully. Thanks a lot again.

1 Like

Excellent! Glad to hear it. (Please post Ruby questions in the Ruby subcategory.)