In Inventor 2019 and lower versions, Cosmetic welds were unable to recognize via Inventor API. Now, Inventor 2020 API is able to identify Cosmetic weld in weldment assembly.
Try below VBA code to know length of Cosmetic weld which is tested with attached weldment assembly (I109269.iam)
Sub Cosmetic_weld()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As WeldmentComponentDefinition
Set oDef = oDoc.ComponentDefinition
Dim oWeld As Weld
For Each oWeld In oDef.Welds
Dim TotalLength As Double
TotalLength = 0
Dim oEdge As Edge
For Each oEdge In oWeld.Edges
Dim oCurveEval As CurveEvaluator
Set oCurveEval = oEdge.Evaluator
Dim MinParam As Double
Dim MaxParam As Double
Dim Length As Double
Call oCurveEval.GetParamExtents(MinParam, MaxParam)
Call oCurveEval.GetLengthAtParam(MinParam, MaxParam, Length)
TotalLength = TotalLength + Length
Next
Debug.Print "Length of " & oWeld.Name & " is " & ThisApplication.UnitsOfMeasure.GetStringFromValue(TotalLength, kMillimeterLengthUnits)
Next
End Sub
Output of VBA code for attached weldment assembly would look like below.
Length of Cosmetic Weld 1 is 189.699 mm Length of Cosmetic Weld 2 is 229.323 mm Length of Cosmetic Weld 3 is 229.323 mm Length of Cosmetic Weld 4 is 189.699 mm Length of Cosmetic Weld 5 is 189.699 mm Length of Cosmetic Weld 6 is 229.323 mm Length of Cosmetic Weld 7 is 229.323 mm Length of Cosmetic Weld 8 is 189.699 mm

Leave a Reply