0

I'm trying to write a sub to essentially check if more than 1 flange was added during the addition of a 'flange feature' to a sheet metal part and if so, were there any that shared a vertex. Essentially, I'm looking for anywhere the corners come together in a nice seam as this indicates that part needs to be welded. I already have a sub that checks for the 'corner seam' feature but when you add 2 flanges side-by-side in the same feature, Inventor automatically adds the same geometry a corner seam would add, but without the feature. I came up with code to look for non-planer or cylindrical faces on the flange since the bend faces get twisted, but the same happens when the base flange isn't square. Is there any way to access the auto-mitered corner feature or... see if the sketches of the flanges share a vertex? Here's the code I currently have working, though not sure this helps at all. Every attempt to look at coinciding vertices just results in too many compile errors of mismatch types and properties that don't exist. Here's the closest I think I've come, but again just a ton of compile errors.

Sub CheckFlangeFeature()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheetMetalCompDef As SheetMetalComponentDefinition
    Set oSheetMetalCompDef = oDoc.ComponentDefinition
    
    Dim oFeatures As SheetMetalFeatures
    Set oFeatures = oSheetMetalCompDef.Features
    
    ' Access the FlangeFeatures collection
    Dim oFlangeFeatures As Object
    Set oFlangeFeatures = oFeatures.FlangeFeatures
    
    Dim oFlangeFeature As Object
    Dim i As Integer
    
    For i = 1 To oFlangeFeatures.Count
        Set oFlangeFeature = oFlangeFeatures.Item(i)
        
        ' Check if the flange feature added more than one flange
        If oFlangeFeature.Faces.Count > 9 Then
            Debug.Print "Flange feature " & oFlangeFeature.Name & " added more than one flange."
            
            ' Check if the sketches of the flanges share a common vertex
            If FlangesShareCommonVertex(oFlangeFeature) Then
                Debug.Print "Flanges in feature " & oFlangeFeature.Name & " share a common vertex."
            End If
        End If
    Next i
End Sub

Function FlangesShareCommonVertex(oFlangeFeature As Object) As Boolean
    Dim oSketch1 As PlanarSketch
    Dim oSketch2 As PlanarSketch
    Dim oVertex1 As SketchPoint
    Dim oVertex2 As SketchPoint
    
    ' Get the sketches of the flanges
    Set oSketch1 = oFlangeFeature.Definition.Sketches.Item(1)
    Set oSketch2 = oFlangeFeature.Definition.Sketches.Item(2)
    
    For Each oVertex1 In oSketch1.SketchPoints
        For Each oVertex2 In oSketch2.SketchPoints
            If oVertex1.Geometry.IsEqualTo(oVertex2.Geometry) Then
                FlangesShareCommonVertex = True
                Exit Function
            End If
        Next oVertex2
    Next oVertex1
    
    FlangesShareCommonVertex = False
End Function
1
  • Not sure what autodesk-inventor is, and I doubt many others do considering it's had less than 20 questions with it tagged in the last ten years, and zero answers. Focus on the VBA element and don't presume we know (or are willing to spend time looking up) what flange/flange feature, vortext, etc mean. Try streamlining this down to a single problem rather than, "debug all the errors in my cdoe..." Commented Feb 3 at 8:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.