Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
aelqabbany
645 Views, 6 Replies

Algorithm - Does plane intersect solid?

I am trying to write an algorithm (subroutine) to determine if a plane intersects a solid. I have prepared the code below which measures the minimum distance between each solid face to the plane, and it works, but it is very slow, especially as parts get larger and more complex.

 

Does anyone have an idea for a faster solution?

Thanks in advance

Sub Main()
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
	Dim Solid1 As SurfaceBody = oCompDef.SurfaceBodies(1)
	Dim Plane As WorkPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Select Plane")
	MessageBox.Show(PlaneIntersectSolid(Solid1,Plane),"Does Plane intersect solid 1?")
	
End Sub

Function PlaneIntersectSolid(Solid1 As SurfaceBody, Plane As WorkPlane) As Boolean
	For Each oFace As Face In Solid1.Faces
		If ThisApplication.MeasureTools.GetMinimumDistance(Plane, oFace) = 0 Then
			PlaneIntersectSolid = True
			Exit Function
		End If
	Next
	PlaneIntersectSolid = False
End Function