Locating intersection of plane and edge

Locating intersection of plane and edge

llorden4
Collaborator Collaborator
521 Views
5 Replies
Message 1 of 6

Locating intersection of plane and edge

llorden4
Collaborator
Collaborator

I'm struggling to find a good method to find an intersection of an edge and a plane in a Part file.  I am familiar with using an IntersectWithCurve method, but I've only had success with that feature when using LineSegments.  Since the part shapes can have a very diverse configuration, I'm attempting to avoid having to evaluate every edge just to recreate them as a LineSegement; is that possible to do or is that a step I'm just not allowed to skip, or is there another approach I can take to find these points of intersection?

 

Here's an example of what I'm attempting to achieve...

llorden4_0-1720449541151.png

 

Autodesk Inventor Certified Professional
0 Likes
Accepted solutions (1)
522 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @llorden4.  I do not really need to use those types of code based tools that often, but another one that comes to mind for that type of situations is the following:

TransientGeometry.SurfaceSurfaceIntersection 

...where you could get the 'transient' inputs from WorkPlane.Plane property, and the Face.Geometry property.  I do not recall if I have ever used that one before, but it did come to mind, so I figured it may be worth mentioning.  There are a couple other similar ones under the TransientGeometry object, but they are betting more 3D line/arc oriented, rather than surface oriented.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @llorden4

 

I think this will work.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face.")

Dim oPlane As WorkPlane
oPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select a work plane.")

Dim oDef As PartComponentDefinition
oDef = oPlane.Parent

Dim oWorkPoint As WorkPoint
Dim oPoint As Point
Dim oIntersectPoints As ObjectsEnumerator

For Each oEdge As Edge In oFace.Edges

	oIntersectPoints = Nothing
	oIntersectPoints = ThisApplication.TransientGeometry.CurveSurfaceIntersection(oEdge.Geometry, oPlane.Plane)

	If oIntersectPoints Is Nothing Then Continue For

	For Each oPoint In oIntersectPoints
		oWorkPoint = oDef.WorkPoints.AddFixed(oPoint)
	Next
Next

 

EESignature

Message 4 of 6

Curtis_Waguespack
Consultant
Consultant

This seemed useful, so I tailored this to set points at all edges in the part that intersect with the plane. Here's the updated version.

 

Dim oPlane As WorkPlane
oPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select a work plane.")
If oPlane Is Nothing Then Exit Sub

Dim oDef As PartComponentDefinition
oDef = oPlane.Parent

Dim oWorkPoint As WorkPoint
Dim oIntersectPoints As ObjectsEnumerator
Dim oPrefix = "WP_"

For Each oWorkPoint In oDef.WorkPoints
	If oWorkPoint.Name.Contains(oPrefix) Then oWorkPoint.Delete
Next

i = 1
For Each oBody As SurfaceBody In oDef.SurfaceBodies
	For Each oFace As Face In oBody.Faces
		For Each oEdge As Edge In oFace.Edges

			oIntersectPoints = Nothing
			oIntersectPoints = ThisApplication.TransientGeometry.CurveSurfaceIntersection(oEdge.Geometry, oPlane.Plane)

			If oIntersectPoints Is Nothing Then Continue For

			For Each oPoint As Point In oIntersectPoints
				oExists = False
				For Each oWorkPoint In oDef.WorkPoints
					If oWorkPoint.Point.DistanceTo(oPoint) = 0 Then oExists = True
				Next

				If oExists = True Then Continue For

				oWorkPoint = oDef.WorkPoints.AddFixed(oPoint)
				oWorkPoint.Name = oPrefix & i
				i = i + 1
			Next 'point
		Next 'edge
	Next 'face
Next 'body

 

EESignature

Message 5 of 6

Stakin
Collaborator
Collaborator
I think we should only compare the work points generated by intersections, excluding other predefined work points and system default work points.

For Each oWorkPoint In oDef.WorkPoints(of WorkPoint).Where(Function(oWk) oWk.Name.Contains(oPrefix))
If oWorkPoint.Point.DistanceTo(oPoint) = 0 Then oExists = True
Next
Message 6 of 6

llorden4
Collaborator
Collaborator

There we go, I wasn't too far off and was just missing the ".Geometry" after the oEdge object.

 

Thanks.

Autodesk Inventor Certified Professional