Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic: Sheet Metal - Find parallel bends

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
wood.isbell
1304 Views, 6 Replies

iLogic: Sheet Metal - Find parallel bends

Does anyone know an efficient way to calculate if all of the bends on a sheet metal part are parallel from either a flat view in a drawing or a flat pattern?

 

More info:

 

I am trying to find a way to determine if all of the bends on a sheet metal part are along the same dimension, or parallel. I thought this would be easy using the flat pattern or even the curve in the drawing I am creating, but I am stumped.

 

 

 

I am starting with a sheet metal part with a flat pattern, but the designs can change drastically. For a part with only parallel bends, I want to place a larger flat view and a single view of the two dimensions needed to represent the folded part. (i.e. a flat front view and a right side formed view). Normally, for a part with more dimensions involved in the bend, I would have more views to represent the formed part.

 

6 REPLIES 6
Message 2 of 7
rjay75
in reply to: wood.isbell

Not sure about the drawing part but if you have a generated the flatpattern on the part you could go through the FlatBendResult objects and see if they all are beding in the same direction. (Up/Down) You can get to them through SheetMetalComponentDefinition.FlattPattern.FlatBendResults.

Message 3 of 7
wood.isbell
in reply to: rjay75

Thank you for the response.

 

Yes, I can pretty easily get the bend direction and angle for each of them, but what I really need is the direction of the bend line rather than the bend feature, so that I can compare the angle of it to the other bends. A simple example would be a "C"-shaped part compared to a closed box part. The "C" shape would have two bends parallel to one another, but the box would have at least four bends. Two sets of bends would be parallel, so I would rule it out in this case.

 

I hope that is a little bit more clear. The reason I mentioned using the drawing view as a possibility is because I already have a piece of code iterating through the bend edges on a flat view in order to place Bend Notes, but I have not figured a way to calculate their relative angles from one another.

Message 4 of 7
rjay75
in reply to: wood.isbell

Using the angles and the bends if your bends are in some kind of logical order you could traverse the bends adding up the angles. For instance in your C shape you pick a starting bend. One side is your starting panel and consider it at angle 0, the next panel includes the bend angle so it's at angle 90. Going around you add up the angles of the bend comparing the angles along the way. So each panel is paired with an angle. All the panels that have a difference/sum of angles at 0, 180, 360 (multiples of 180) etc.. are parallel.

 

That may be a naive way of looking at it but it may help if you can think of a way to use multiples of angles to figure what you need,

Message 5 of 7
rjay75
in reply to: wood.isbell

Another thing I just thought of is you can use the FlatPattern.GetEdgesOfType(kBendDownFlatPatternEdge, true) [Get all down bend edges on from the top face] and measure there angles to make sure you are comparing only the ones parallel to each other. You can probable go back from there to the original bend to see get the bend angles. 

Message 6 of 7
nmunro
in reply to: wood.isbell

Here is some code (VBA) that should get you going. There is no error checking and it is fairly basic but it does tell you whether all bend lines are parallel or not.

 

Public Sub BendAngles()
    
    Dim doc As PartDocument
    Set doc = ThisDocument
    
    Dim direction As UnitVector
    Dim i As Integer
    Dim bendLine As LineSegment
    Dim allInSameDirection As Boolean
    
    allInSameDirection = True
    
    Dim compDef As SheetMetalComponentDefinition
    Set compDef = doc.ComponentDefinition
    
    Dim bends As FlatBendResults
    Set bends = compDef.FlatPattern.FlatBendResults
    
    Dim bend As FlatBendResult
    
    For i = 1 To bends.Count
        Set bend = bends(i)
        Set bendLine = bend.Edge.Geometry
        If i = 1 Then
            Set direction = bendLine.direction
        Else
            If Not bendLine.direction.IsParallelTo(direction, 0.001) Then
                allInSameDirection = False
                Exit For
            End If
        End If
    Next i
    
    If allInSameDirection Then
        MsgBox ("Bend lines are all parallel")
    Else
        MsgBox ("Bend lines are not parallel")
    End If
    
End Sub

 

Neil

        


https://c3mcad.com

Message 7 of 7
wood.isbell
in reply to: nmunro

nmunro, thank you! This is exactly what I was looking for. I changed yours a bit to assume false since I am a negative person and some of my parts have no bends (which I actually catch otherwise). Yours works great, though!

 

 

Public Sub BendAngles()
    
    Dim doc As PartDocument
    Set doc = ThisDocument
    
    Dim direction As UnitVector
    Dim i As Integer
    Dim bendLine As LineSegment
    Dim allInSameDirection As Boolean
    
    allInSameDirection = False
    
    Dim compDef As SheetMetalComponentDefinition
    Set compDef = doc.ComponentDefinition
    
    Dim bends As FlatBendResults
    Set bends = compDef.FlatPattern.FlatBendResults
    
    Dim bend As FlatBendResult
    
    For i = 1 To bends.Count
        Set bend = bends(i)
        Set bendLine = bend.Edge.Geometry
        If i = 1 Then
            Set direction = bendLine.direction
        Else
            If Not bendLine.direction.IsParallelTo(direction, 0.001) Then
                allInSameDirection = False
                Exit For
            Else If bendLine.direction.IsParallelTo(direction, 0.001) Then
                allInSameDirection = True
            End If
        End If
    Next i
    
    If allInSameDirection Then
        MsgBox ("Bend lines are all parallel")
    Else
        MsgBox ("Bend lines are not parallel")
    End If
    
End Sub

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report