Q: When I select a bend line in a drawing view, I would like to have access to its flat bend results, such as the bend direction, bend angle and bend radius.
A: The following VBA example finds the bend results corresponding to a bend line from a drawing view. Before running this code select a bend line in a drawing document that belongs to the flat bend pattern of a SheetMetal Part.
Private Sub GetBendResultFromSelectedCurve()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
'Gets the selected curve segment
Dim oDwCurveSegment As DrawingCurveSegment
Set oDwCurveSegment = oDoc.SelectSet.Item(1)
'Gets full drawing curve from the segment
Dim oDrawingCurve As DrawingCurve
Set oDrawingCurve = oDwCurveSegment.Parent
'Gets edge
Dim oEdge As Edge
Set oEdge = oDrawingCurve.ModelGeometry
'Retrieves component definition from the edge
Dim oSMDef As SheetMetalComponentDefinition
Set oSMDef = oEdge.Parent.ComponentDefinition
Dim oFlatPattern As FlatPattern
Set oFlatPattern = oSMDef.FlatPattern
'Gets flat bend result corresponding to the edge
Dim oBendResult As FlatBendResult
Set oBendResult = oFlatPattern.FlatBendResults.Item(oEdge)
'Prints Flat Bend Results
Debug.Print "---------------- Flat Bend Infos ----------------"
Debug.Print "Internal Name: " & oBendResult.InternalName
If oBendResult.IsOnBottomFace Then
Debug.Print "Bend On Bottom Face"
Else
Debug.Print "Bend On Top Face"
End If
Dim oUOM As UnitsOfMeasure
Set oUOM = oDoc.UnitsOfMeasure
Debug.Print "Bend Angle = " & oUOM _
.GetStringFromValue( _
oBendResult.Angle, _
kDefaultDisplayAngleUnits)
Debug.Print "Bend Radius = " & oUOM _
.GetStringFromValue( _
oBendResult.InnerRadius, _
kDefaultDisplayLengthUnits)
If oBendResult.IsDirectionUp Then
Debug.Print "Bend Direction: " & "Bend Up"
Else
Debug.Print "Bend Direction: " & "Bend Down"
End If
Debug.Print "-------------------------------------------------"
Beep
End Sub