Message 1 of 3

Not applicable
06-07-2020
09:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
Is there any way to select all co-planar faces of a selected face of a part in an assembly? I found a solution for the part context but still can not apply for the assembly.
Please help me in this case. Thanks in advance 🙂
Here is my code that I did try:
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
g_assemblyDoc = g_inventorApplication.ActiveDocument
Dim _selectSet As Inventor.SelectSet
_selectSet = g_assemblyDoc.SelectSet
For i = 1 To _selectSet.Count
Dim _faceProxy As Inventor.FaceProxy
_faceProxy = _selectSet.Item(i)
Dim _face As Inventor.Face
_face = _faceProxy.NativeObject
Dim _doc As Inventor.Document
_doc = _face.Parent.ComponentDefinition.Document
Dim _partDoc As Inventor.PartDocument
_partDoc = g_inventorApplication.Documents.ItemByName(_doc.FullDocumentName)
Dim params(1) As Double
params(0) = 0.5
params(1) = 0.5
' Get point on surface at param .5,.5
Dim points(2) As Double
Call _face.Evaluator.GetPointAtParam(params, points)
' Create point object
Dim oPoint As Inventor.Point
oPoint = g_inventorApplication.TransientGeometry.CreatePoint(points(0), points(1), points(2))
' Get normal at this point
Dim normals(2) As Double
Call _face.Evaluator.GetNormal(params, normals)
' Create normal vector object
Dim oNormal As Inventor.Vector
oNormal = g_inventorApplication.TransientGeometry.CreateVector(normals(0), normals(1), normals(2))
Dim RefPlane As Inventor.Plane
RefPlane = g_inventorApplication.TransientGeometry.CreatePlane(oPoint, oNormal)
Dim bodies As Inventor.SurfaceBodies
bodies = _partDoc.ComponentDefinition.SurfaceBodies
Dim BodyFace As Inventor.Face
Dim PlaneB As Inventor.Plane
For Each Body In bodies
For Each BodyFace In Body.faces
If BodyFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then
Call BodyFace.Evaluator.GetPointAtParam(params, points)
' Create point object
oPoint = g_inventorApplication.TransientGeometry.CreatePoint(points(0), points(1), points(2))
Call _face.Evaluator.GetNormal(params, normals)
oNormal = g_inventorApplication.TransientGeometry.CreateVector(normals(0), normals(1), normals(2))
PlaneB = g_inventorApplication.TransientGeometry.CreatePlane(oPoint, oNormal)
'Check if they are co-planar
If PlaneB.IsCoplanarTo(RefPlane) Then
Call _partDoc.SelectSet.Select(BodyFace)
End If
End If
Next
Next
Next
End Sub
Solved! Go to Solution.