I want to select the planar face of a slot by selecting one of its non-circular edges.
This is the code I am using, this selects an edge and evaluates which one of all the faces in the part is normal to that edge. Then I can filter to check which one of the normal faces contains that specific edge (which I haven't coded in this example yet).
Dim oEdge As Edge Dim oFace As Face Dim FaceParams(3) As Double Dim FaceNormals(2) As Double Dim oUnitNormal As UnitVector = Nothing oTransGeom = ThisApplication.TransientGeometry oEdge = ThisApplication.CommandManager.Pick(kPartEdgeFilter, "Select the slot") For i = 1 To oEdge.Parent.Faces.Count oFace = oEdge.Parent.Faces(i) oFace.Evaluator.GetNormal(FaceParams, FaceNormals) oUnitNormal = ThisApplication.TransientGeometry.CreateUnitVector(FaceNormals(0), FaceNormals(1), FaceNormals(2)) MsgBox("Face X: " & oUnitNormal.X _ & vbLf & "Face Y: " & oUnitNormal.Y _ & vbLf & "Face Z: " & oUnitNormal.Z) Next i
The problem is that there are two faces that contain that edge and are also normal to it.
How can I filter to get that slot internal face and not the external one?
Thank you in advance
I want to select the planar face of a slot by selecting one of its non-circular edges.
This is the code I am using, this selects an edge and evaluates which one of all the faces in the part is normal to that edge. Then I can filter to check which one of the normal faces contains that specific edge (which I haven't coded in this example yet).
Dim oEdge As Edge Dim oFace As Face Dim FaceParams(3) As Double Dim FaceNormals(2) As Double Dim oUnitNormal As UnitVector = Nothing oTransGeom = ThisApplication.TransientGeometry oEdge = ThisApplication.CommandManager.Pick(kPartEdgeFilter, "Select the slot") For i = 1 To oEdge.Parent.Faces.Count oFace = oEdge.Parent.Faces(i) oFace.Evaluator.GetNormal(FaceParams, FaceNormals) oUnitNormal = ThisApplication.TransientGeometry.CreateUnitVector(FaceNormals(0), FaceNormals(1), FaceNormals(2)) MsgBox("Face X: " & oUnitNormal.X _ & vbLf & "Face Y: " & oUnitNormal.Y _ & vbLf & "Face Z: " & oUnitNormal.Z) Next i
The problem is that there are two faces that contain that edge and are also normal to it.
How can I filter to get that slot internal face and not the external one?
Thank you in advance
This is just a conceptual thought, but if the Edge belongs to an ExtrudeFeature, you could find the ExtrudeFeature that it belongs to by looping through all the ExtrudeFeatures, looping the ExtrudeFeature.SideFaces collection, and checking their Edges against the one you selected (using 'Is', not '=') and when you find a match, you will also have the feature's side face.
Wesley Crihfield
(Not an Autodesk Employee)
This is just a conceptual thought, but if the Edge belongs to an ExtrudeFeature, you could find the ExtrudeFeature that it belongs to by looping through all the ExtrudeFeatures, looping the ExtrudeFeature.SideFaces collection, and checking their Edges against the one you selected (using 'Is', not '=') and when you find a match, you will also have the feature's side face.
Wesley Crihfield
(Not an Autodesk Employee)
I don't understand which face you want to get from the edge, but you can try this code sample
Dim part As PartDocument = ThisDoc.Document
'Select an edge
Dim edge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeLinearFilter, "Select edge")
'Iterate faces which belongs to the edge
For Each connectedFace As Face In edge.Faces
'Slot feature has exactly 4 tangentially connected faces
If connectedFace.TangentiallyConnectedFaces.Count <> 3 Then Continue For
'Slot feature has exactly 2 planar faces and 2 cylinder faces
'Variable connectedFace is one of the planar faces
Dim planarFacesCount As Integer
Dim cylinderFacesCount As Integer
For Each tangentFace As Face In connectedFace.TangentiallyConnectedFaces
If tangentFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then cylinderFacesCount += 1
If tangentFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then planarFacesCount += 1
Next
'Check tangentially connecte faces count by its type
If planarFacesCount = 1 And cylinderFacesCount = 2 Then
'Variable connectedFace is candidate for slot feature
part.SelectSet.Select(connectedFace)
Return
End If
Next
MsgBox("This is not a slot feature edge")
I don't understand which face you want to get from the edge, but you can try this code sample
Dim part As PartDocument = ThisDoc.Document
'Select an edge
Dim edge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeLinearFilter, "Select edge")
'Iterate faces which belongs to the edge
For Each connectedFace As Face In edge.Faces
'Slot feature has exactly 4 tangentially connected faces
If connectedFace.TangentiallyConnectedFaces.Count <> 3 Then Continue For
'Slot feature has exactly 2 planar faces and 2 cylinder faces
'Variable connectedFace is one of the planar faces
Dim planarFacesCount As Integer
Dim cylinderFacesCount As Integer
For Each tangentFace As Face In connectedFace.TangentiallyConnectedFaces
If tangentFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then cylinderFacesCount += 1
If tangentFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then planarFacesCount += 1
Next
'Check tangentially connecte faces count by its type
If planarFacesCount = 1 And cylinderFacesCount = 2 Then
'Variable connectedFace is candidate for slot feature
part.SelectSet.Select(connectedFace)
Return
End If
Next
MsgBox("This is not a slot feature edge")
Can't find what you're looking for? Ask the community or share your knowledge.