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

CAD tip CAD tip # 13963:

Question CAD 
 %  platform  category 
Q - question

Sum of pipe element lengths in Inventor (iLogic).

A - answer 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 (
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
			PL = customPropSet.Item("PL").Value 'string
			PL = uom.GetValueFromExpression(PL, _
			TotalL = TotalL + PL
		End Try
	End If
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:

100% *  CAD 
16.12.2023    21544×  
Prices - CAD eShop:
applies to: Inventor ·

See also:
Tip 13965:Total length of sweeps in Inventor - wires, pipes, trusses, tubes, hoses (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 add-on functions for AutoCAD Civil 3D
CADstudio Civil 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.