The following iLogic macro counts the total length of all pipe segments in the "Tube and Pipe" environment in the Autodesk Inventor assembly.
Run the macro in the assembly environment, not in an open Pipe, Pipe run or Route.
'Add lengths of all pipes (CADforum.cz)
Dim docFile As Document
Dim customPropSet As PropertySet
Dim oDocInts As DocumentInterests
Dim bHas_TP_Interest As Boolean
Dim TotalL As Double
Dim uom = ThisDoc.Document.UnitsOfMeasure
TotalL = 0
For Each docFile In ThisApplication.ActiveEditDocument.AllReferencedDocuments
customPropSet = docFile.PropertySets.Item("Inventor User Defined Properties")
oDocInts = docFile.DocumentInterests
bHas_TP_Interest = oDocInts.HasInterest("{4D39D5F1-0985-4783-AA5A-FC16C288418C}") 'T&P
If bHas_TP_Interest Then
Try
PL = customPropSet.Item("PL").Value 'string
PL = uom.GetValueFromExpression(PL, _
uom.GetStringFromType(UnitsTypeEnum.kDefaultDisplayLengthUnits))
TotalL = TotalL + PL
Catch
End Try
End If
Next
MsgBox("Total length:" & vbCrLf & vbCrLf & _
uom.GetStringFromValue(TotalL, UnitsTypeEnum.kDefaultDisplayLengthUnits), _
MsgBoxStyle.Information, "Pipe lengths")
Another option for obtaining pipe, hose, and tube lengths is the Tube&Pipe assembly BOM - the sum of the Pcs column containing the segment lengths.
You can also get information about the lengths of the segments that make up a pipe assembly by double-clicking on a specific route in the browser tree: