' Add a Trigger for Part Geometry Change ' standard code found in the Inventor Api Help ' Added to API code: create a parameter for each sweep with the name of the sweep ' Set a reference to the active part document Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition oDef = oDoc.ComponentDefinition 'create an array to store all sweep lengths Dim myArrayList As New ArrayList 'iterate trhu the part and create for each sweep a parameter that contains the length For Each xSweep In oDef.Features.SweepFeatures 'check if sweep is suppressed, if True then do nothing If xSweep.Suppressed() = True Then ' MessageBox.Show("Sweep is Suppressed", "Title") Else 'add sweeplength to array Dim opath As Path opath = xSweep.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 'add value of sweep to Array myArrayList.add(TotalLength) End If Next 'Calculate all value's in the array Dim sum As Double For Each item As Double In myArrayList sum += item Next 'show total of sweep lengths MessageBox.Show("Total sweep length: " & sum*10, "Total sweep length") 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 = "L" Then exists = True Next oparam 'Change the value if the parameter exists otherwise add the parameter If exists Then oparams.Item("L").Value = sum Else oparams.UserParameters.AddByValue("L", sum, 11266) End If oDoc.Update