CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 7704

CAD tip CAD tip # 13965:

Question CAD 
 %  platform  category 
Q - question

Total length of sweeps in Inventor - wires, pipes, trusses, tubes, hoses (iLogic)

A - answer 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
	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 :

For possible bulk selection of ALL sweeps in the model, use the loop (instead of While True):

For Each oSweep In oDef.Features.SweepFeatures

100% *  CAD 
17.12.2023    26095×  
Prices - CAD eShop:
applies to: Inventor ·

See also:
Tip 13963:Sum of pipe element lengths in Inventor (iLogic).
Tip 13040:iLogic - display information about complexity of an Inventor part.
Tip 12392:Export unfolds of sheetmetal parts to DXF - parameters for iLogic and VBA
Tip 11211:Mass change of units in the whole Inventor assembly.
Tip 9952:iLogic rule - check whether iProperties are overridden.

Back   All CAD Tips

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   

Increase your productivity with our set of BIM add-on functions for Autodesk Revit
CADstudio Revit Tools More info

Please use these tips at your own risk.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.