Some years ago a kind person provided the attached iLogic code. As I recall, the name of the sweep feature or the sketch has to match the one referenced in the code.
'Set a reference to the active part document
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
oDef = oDoc.ComponentDefinition
Dim opath As Path
opath = oDef.Features.SweepFeatures.Item("TheSweep").Path
Dim TotalLength As Double
TotalLength = 0
Dim oCurve As Object
Dim i As Integer
For i = 1 To opath.Count
oCurve = opath.Item(i).Curve
Dim oCurveEval As CurveEvaluator
oCurveEval = oCurve.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 i
Dim oparams As Parameters
Dim oparam As Parameter
oparams = oDoc.ComponentDefinition.Parameters
Dim exists As Boolean
exists = False
'Find out if parameter exists
For Each oparam In oparams
If oparam.Name = "Sweeplength" Then exists = True
Next oparam
'Change the value if the parameter exists otherwise add the parameter
If exists Then
oparams.Item("Sweeplength").Value = TotalLength
Else
oparams.UserParameters.AddByValue( "Sweeplength", TotalLength, 11266)
End If
oDoc.Update
Here are some more ilogic methods:
https://forums.autodesk.com/t5/inventor-forum/sweep-length-measurement/m-p/9567405#M791937
Steve Walton
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Inventor 2025
Vault Professional 2025