- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am not sure if this is what @MjDeck had in mind about dealing with concave vs convex, but I created a custom Function, paired with a custom Enum, for determining if two faces are concave or convex. Then I used the result of that to determine if the angle between the two faces should be 'as computed' (inside angle), or inverted (outside angle). It's likely not as error proof as it could be, but it seemed to work OK in my initial testing.
It first essentially determines if the two 'input' faces have a common edge. If they do not, then these faces can not really be labeled either concave or convex, as far as I understand anyways. Then, it uses the tools already available to us for finding concave or convex edges of a body. Based on if the 'common edge' is considered concave or convex, that determines if the faces are concave or convex to each other. Then, as stated before, if they are convex, I invert the measured angle between them to essentially be 360 degrees minus the measured angle, to get its inverse. You can use that association however you want though.
Sub Main
Dim oFace1 As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select Face 1")
If oFace1 Is Nothing Then Return
Dim oFace2 As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select Face 2")
If oFace2 Is Nothing Then Return
Dim eResult As ConcaveConvexOrNeitherEnum = CheckFacesForConcaveOrConvex(oFace1, oFace2)
Dim dAngle As Double = (ThisApplication.MeasureTools.GetAngle(oFace1, oFace2) * (180/Math.PI))
If eResult = ConcaveConvexOrNeitherEnum.Concave Then 'inside angle
'do nothing
ElseIf eResult = ConcaveConvexOrNeitherEnum.Convex Then 'outside angle
dAngle = (360 - dAngle) 'invert angle
End If
MsgBox("Faces are " & eResult.ToString & " and," & vbCrLf & _
"Angle = " & dAngle.ToString & " deg.", vbInformation, "iLogic")
End Sub
Public Enum ConcaveConvexOrNeitherEnum
Concave
Convex
Neither
End Enum
Function CheckFacesForConcaveOrConvex(oFace1 As Face, oFace2 As Face) As ConcaveConvexOrNeitherEnum
'find the common edge between those two faces
Dim commonEdge As Edge
For Each oEdge As Edge In oFace1.Edges
If oEdge.Faces.Count > 1 Then
For Each oOtherFace In oEdge.Faces
If oOtherFace Is oFace2 Then
commonEdge = oEdge
Exit For
End If
Next oOtherFace
End If
If commonEdge IsNot Nothing Then Exit For
Next oEdge
If commonEdge Is Nothing Then
'Logger.Debug("No common edge found!", vbExclamation, "iLogic")
Return ConcaveConvexOrNeitherEnum.Neither
End If
Dim oCCEs As EdgeCollection = oFace1.Parent.ConcaveEdges
'Logger.Info("ConcaveEdges = " & oCCEs.Count)
Dim oCVEs As EdgeCollection = oFace1.Parent.ConvexEdges
'Logger.Info("ConvexEdges = " & oCVEs.Count)
If oCCEs IsNot Nothing AndAlso oCCEs.Count > 0 Then
For Each oConcaveEdge As Edge In oCCEs
If oConcaveEdge Is commonEdge Then
Return ConcaveConvexOrNeitherEnum.Concave
End If
Next oConcaveEdge
End If
If oCVEs IsNot Nothing AndAlso oCVEs.Count > 0 Then
For Each oConvexEdge As Edge In oCVEs
If oConvexEdge Is commonEdge Then
Return ConcaveConvexOrNeitherEnum.Convex
End If
Next oConvexEdge
End If
Return ConcaveConvexOrNeitherEnum.Neither
End Function
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS)
.
Wesley Crihfield
(Not an Autodesk Employee)