How to judge whether two models have intersection

There are two models inside the scene, model 1 is the model inserted by add_instance method and Model 2 is created by pushpull method.
I want to write code through rubyAPI, how can I determine if the two models have intersection?
I would be very grateful if you could provide me with some help!

here is the picture:

I had the same problem. The method is “intersect_with”. The following link helps me to understand it.

1 Like

This problem has been discussed several times here. Please use the forum search feature to find these topics.

1 Like

Thanks a lot!

Can you share the model please? Is “model 2” un-grouped geometry that is connected to that ground face?

intersect_with creates geometry. Sounds like the original poster just want to check if they overlap in space. (Correct?)

int_sec = cube_entities.intersect_with(recursion,cube_trans,cube_entities,cube_trans,false,[group2])

if int_sec.size = 0 means no intersect.
if int_sec.size = 1 means intersect is a line
if int_sec.size = 2 means intersect is a sheet
if int_sec.size >= 3 means intersect is a volume
am I right?

Yes, but intersecting creating geometry which means it modifies the model and it’s slow. It works, but not ideal.

1 Like

What is a better solution? You are right in this way if we just want to know about intersect we waste time.

Depends on the model. Awaiting more information from the original poster.

Thank you sir!
The model above was deleted and I created a new one.
How to judge whether model 1 and model 2 intersect, or model 1 is inside model 2.

model.skp (543.9 KB)

The coordinates of model 1 can be obtained through entity.transformation.origin method, whether it can be judged according to the coordinate relationship between model 1 and model 2.

Is the model always a cube shape? Or is that a simplification?

model1 is Always a cube shape, the shape of model 2 is uncertain.