Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Extract bendID or bendorder number from flatpattern

Anonymous

Extract bendID or bendorder number from flatpattern

Anonymous
Not applicable

Hello Does anyone know how to extract the bend ID's and Bend order number from the 3D sheetmetal part.

 

Counting bends does not return the same number at the Bend ID i a 2D bend table.

 

I want to get the highest bendorder number from the sheetmetal part.

 

maybe counting bendlines does the trick.

 

Can some one please help.

 

Regards Kent boettger.

0 Likes
Reply
Accepted solutions (1)
705 Views
7 Replies
Replies (7)

Vladimir.Ananyev
Alumni
Alumni

Hi Kent,

could you please upload your SheetMetal model for test purposes?

It would be great if you add some description as well (what you want to get from the model).

thanks,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes

Anonymous
Not applicable

Hello Vladimir,

 

Here is an example of a part / drawing and a description on what i want to do, extract and why.

 

hope you can help.

 

regards. Kent boettger

0 Likes

Anonymous
Not applicable

Any help here? Please.

0 Likes

Vladimir.Ananyev
Alumni
Alumni

 Here is my test for the flange feature #1 in your sheet metal model.

 

Flange.jpg

 

Sub Test()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oDef As SheetMetalComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    Dim oFlangeFeatures As FlangeFeatures
    Set oFlangeFeatures = oDef.Features.FlangeFeatures
    Debug.Print "FlangeFeatures.Count = " & oFlangeFeatures.Count
    
    ' Get the flange feature.
    Dim oFlange As FlangeFeature
    Set oFlange = oFlangeFeatures.Item(1)
    
    ' Position the end of part marker to just before this feature so the
    ' edges are in their original state.
    Call oFlange.SetEndOfPart(True)

    Dim oFlangeDef As FlangeDefinition
    Set oFlangeDef = oFlange.Definition

    Dim oEdge As Edge
    Set oEdge = oFlangeDef.Edges.Item(1)
    
    Dim Length As Double
    
        'calculation of the edge length
        Dim oCurveEval As CurveEvaluator
        Set oCurveEval = oEdge.Evaluator
        Dim MinParam As Double
        Dim MaxParam As Double
        Call oCurveEval.GetParamExtents(MinParam, MaxParam)
        Call oCurveEval.GetLengthAtParam(MinParam, MaxParam, Length)
        
    Debug.Print "Length, cm = " & Length
    
    ' Set the stop node back to the bottom of the browser.
    Call oDef.SetEndOfPartToTopOrBottom(False)
    
    Beep
End Sub

Results:

FlangeFeatures.Count = 3
Length, cm = 10

Hope this could help.

cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes

Anonymous
Not applicable

Hello Vladimir.

 

This is nice but actually not what i am locking for?

 

your code will not work when we have cosmetic bendlines in the model.?

 

here is my code so fare.

 

I want to be able to get the bend order number attached to each bendline in the model.

 

this will give us the rigth bend count. see attached model, picture and code.

 

The bend count on the attached model will be 9, this is wrong.

 

But the highest bend order number in the flatpattern is 7, this is right

 

I want to read out the highest bend order number "7".

 

please help.

 

regards kent boettger

 

        Dim m_invapp As Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

        ' Set a reference to the sheet metal document.
        ' This assumes a part document is active.

        Dim oPartDoc As PartDocument

        oPartDoc = m_invapp.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) = True Then

            oSheetMetalCompDef.Unfold()

        End If

        Dim oFlatPattern As FlatPattern

        oFlatPattern = oSheetMetalCompDef.FlatPattern

        Dim oBendResults As FlatBendResults = oFlatPattern.FlatBendResults

        MsgBox("Bendlines = " & oBendResults.Count / 2)

        Dim oTotalBends As Integer = oBendResults.Count / 2

        Dim oBendresult As FlatBendResult

        For Each oBendresult In oBendResults

            ' Here i want to get the bend order number attached to the bendline?
            ' but i dont know how to do this.

            Dim oBendordernumber As Integer = oBendresult.GetBendOrder()

        Next
0 Likes

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

Hi Kent,

 

So is this all that's missing for you?

        Dim oBendorderNumber As Long
        Dim oBendorderSource As BendOrderSourceTypeEnum
        Call oBendresult.GetBendOrder(oBendorderNumber, oBendorderSource)

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes

Anonymous
Not applicable

Thanks Adam, Just what i was looking for.

 

 Dim oFlatPattern As FlatPattern

        oFlatPattern = oSheetMetalCompDef.FlatPattern

        Dim oBendResults As FlatBendResults = oFlatPattern.FlatBendResults

        'Dim oTotalBends As Integer = oBendResults.Count / 2 ( This was wrong )

        Dim oBendresult As FlatBendResult

        Dim oBendCountReal As Long = Nothing

        For Each oBendresult In oBendResults

            Dim oBendordernumber As Long
            Dim oBendorderSource As BendOrderSourceTypeEnum

            Call oBendresult.GetBendOrder(oBendordernumber, oBendorderSource)

            If oBendordernumber > oBendCountReal Then

                oBendCountReal = oBendordernumber

            End If

        Next

        'MsgBox("oBendCountReal = " & oBendCountReal)

        Return oBendCountReal
0 Likes