Over 1.096.000 registered users (EN+CZ).
AutoCAD tips, Inventor tips, Revit tips.
Try the new precise Engineering calculator and the updated Barcode generator.
New AutoCAD 2026 commands and variables.
CAD tip # 13965:
Question
A
Using the iLogic rule detecting 3D features of Sweeps, you can sum the total length of all picked elements of this type in your 3D model (IPT component). This can be used, for example, to find the total length of modelled pipe elements, wires, hoses, profile beams, trusses and other swept elements.
End the incremental loop displaying the cumulative length by pressing [ESC]. Then the total length value (in the current document length units) is displayed for copying.
oPrecision = 4 Dim TotalLength As Double Dim oSweep As SweepFeature Dim oDoc = ThisDoc.Document Dim oDef As PartComponentDefinition oDef = oDoc.ComponentDefinition Dim oHighLight As Inventor.HighlightSet oHighLight = oDoc.CreateHighlightSet On Error GoTo ExitRule oUOM = oDoc.UnitsOfMeasure oLUnits = oUOM.LengthUnits oUnitString = oUOM.GetStringFromType(oLUnits) Dim cnt As Integer = 0 Dim oPrompt As String oPrompt = "Select Sweeps, <ESC> to end..." While True 'loop selectF = ThisApplication.CommandManager.Pick _ (kPartFeatureFilter, oPrompt) If IsNothing(selectF) Then Exit While If TypeOf selectF Is SweepFeature Then oSweep = selectF Dim oProfileOrigin As Point2d oProfileOrigin = oSweep.Profile.RegionProperties.Centroid Dim oProfileOrigin3D As Point oProfileOrigin3D = oSweep.Profile.Parent.SketchToModelSpace(oProfileOrigin) Dim oCurves As ObjectsEnumerator oCurves = oDef.Features.SweepFeatures.GetTruePath(oSweep.Path, oProfileOrigin3D) Dim oCurve As Object For Each oCurve In oCurves 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 cnt = cnt + 1 Call oHighLight.AddItem(selectF) oPrompt = Round(oUOM.ConvertUnits(TotalLength, "cm", _ oLUnits), oPrecision) & " " & oUnitString End If End While InputBox("TOTAL LENGTH" & vbCrLf & "of " & cnt & " sweeps:", "Sweep Length", oPrompt) ExitRule : oHighLight.Clear
For possible bulk selection of ALL sweeps in the model, use the loop (instead of While True):
For Each oSweep In oDef.Features.SweepFeatures Next
Inventor


17.12.2023
28109×

applies to: Inventor ·