Inventor: Access sheet metal part bend information from a drawing view

by Vladimir Ananyev

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

<

p style=”line-height: normal;margin: 0cm 0cm 0pt” class=”MsoNoSpacing”>End Sub


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading