How to check the two component instances' intersection


intersection = one_component_instance.intersect(other_component_instance)
puts "#{intersection}" # this print nothing, why ??

# check one component is covered by the other.
if one_component_instance.equal?(intersection) or other_component_instance.equal?(intersection)
    puts "cover"

but it doesn’t work above. who can help me


you need to test if the BoundingBox’s intersect…




Sketchup::ComponentInstance#intersect() says:

If the specified objects (this and arg) do not represent manifold volumes, this method fails.

Boolean solid operations are a Pro ONLY feature.


if two components are in the diffrent groups. does the method works? now i have the global transformation of two components. is there a method that i can combine the global transformation and boundarybox to solve the problem


If bounding boxes do not intersect, then the instances do not intersect. However, if bounding boxes intersect, there’s still no guarantee that the geometry of one intersects that of the other.


I doubt it, but you can always attempt it programmatically.


Dan, I’m suggesting this, and it’s not Pro only

#intersect(boundingbox) ⇒ Object

Note: Prior to SU2015 this method would return incorrect result in some cases.
 For correct result in these versions you must first check if the boundingboxes actually overlap 
- then call this to get the resulting bounding box.

I use this to recurse all entities in all contexts one of my plugins…

it can be slow but it does work

this uses it to cull anything that doesn’t intersect with my selector box, before using the sections to cut the remaining entities…


yes, i find a method. the boundary can build by two points. now i can convert two relative points to global points. then create a new boundary by the global points. in the end i compare the two new boundaries.


John, that is okay, I was replying to the method use of the OP’s example, and the limitations of the API’s Solid Tools method wrappers. Specifically why the OP’s example may have failed. I’ll edit my post to make it more clear what I was replying to. And Wo3Dan replied (which I agreed with,) to your suggestion re the bounding boxes.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.