Counting UP and DOWN bends?

Counting UP and DOWN bends?

spascual
Collaborator Collaborator
769 Views
8 Replies
Message 1 of 9

Counting UP and DOWN bends?

spascual
Collaborator
Collaborator

Hi Sirs,

I have seen a discussion about counting bends code, any iluminated codemaker could help me to do the same but with up and down count?

 

Regards

0 Likes
Accepted solutions (1)
770 Views
8 Replies
Replies (8)
Message 2 of 9

xiaodong_liang
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

FlatBendResult.IsDirectionUp  tells this info. The following is a small code.

 

  Public Sub GetBendResults()
 
        ' Set a reference to the sheet metal document.
        ' This assumes a part document is active.
        Dim oPartDoc As PartDocument
        oPartDoc = _InvApplication.ActiveDocument
 
        ' Make sure the document is a sheet metal document.
        If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
            MsgBox("A sheet metal document must be open.")
            Exit Sub
        End If
 
        Dim oSheetMetalCompDef As SheetMetalComponentDefinition
        oSheetMetalCompDef = oPartDoc.ComponentDefinition
 
        If (Not oSheetMetalCompDef.HasFlatPattern) Then
            oSheetMetalCompDef.Unfold()
        End If
 
        Dim oFlatPattern As FlatPattern
        oFlatPattern = oSheetMetalCompDef.FlatPattern       
 
        Dim oBendResult As FlatBendResult
        For Each oBendResult In oFlatPattern.FlatBendResults
 
            Dim strResult As String
            strResult = "Internal Name: " & oBendResult.InternalName & ", "
 
            If oBendResult.IsOnBottomFace Then
                strResult = strResult & "On Bottom, "
            Else
                strResult = strResult & "On Top, "
            End If
 
            strResult = strResult & "Angle: " & _InvApplication.ActiveDocument.UnitsOfMeasure.GetStringFromValue(oBendResult.Angle, UnitsTypeEnum.kDefaultDisplayAngleUnits) & ", "
 
            strResult = strResult & "Inner Radius: " & _InvApplication.ActiveDocument.UnitsOfMeasure.GetStringFromValue(oBendResult.InnerRadius, UnitsTypeEnum.kDefaultDisplayLengthUnits) & ", "
 
            If oBendResult.IsDirectionUp Then
                strResult = strResult & "Bend Direction: " & "Bend Up"
            Else
                strResult = strResult & "Bend Direction: " & "Bend Down"
            End If  
 
            Debug.Print(strResult)
        Next       
 
    End Sub
Message 3 of 9

spascual
Collaborator
Collaborator

Magnific Smiley Happy

0 Likes
Message 4 of 9

spascual
Collaborator
Collaborator

Hi Sirs,

 

If I just have one bend, why I get this result???

 

Internal Name: 4:4,-1,125,-1, On Bottom, Angle: 75,00 gr, Inner Radius: 0,500 mm, Bend Direction: Bend Up
Internal Name: 1:4,-1,125,-1, On Top, Angle: 75,00 gr, Inner Radius: 0,500 mm, Bend Direction: Bend Up

 

Regards

0 Likes
Message 5 of 9

spascual
Collaborator
Collaborator
I have already understood, the information get.

Thanks a lot
0 Likes
Message 6 of 9

LarsBJepsen
Advocate
Advocate

I'm trying to figure out a way of listing the name of the parrent sheet metal feature containing the bend as well. Any suggestions? 

0 Likes
Message 7 of 9

LarsBJepsen
Advocate
Advocate
Re: Counting UP and DOWN bends?

Hi Sirs,

 

If I just have one bend, why I get this result???

 

Internal Name: 4:4,-1,125,-1, On Bottom, Angle: 75,00 gr, Inner Radius: 0,500 mm, Bend Direction: Bend Up
Internal Name: 1:4,-1,125,-1, On Top, Angle: 75,00 gr, Inner Radius: 0,500 mm, Bend Direction: Bend Up

 

Regards

 

Same issue here 😞 - Does anyone have a solution??

0 Likes
Message 8 of 9

LarsBJepsen
Advocate
Advocate

In Inventor 2020 ilogic the internal name is returned like this: 1:4,-1,1613,-1, also it looks like each bend is checked twice?? Any suggestions?

0 Likes
Message 9 of 9

LarsBJepsen
Advocate
Advocate

I would like to have it returning the bend information (bend 1, bend 2 etc) or even better the name of the parrent feature (flange1, contour flange1, etc)

0 Likes