Get PipeInsulation center reference

I want get PipeInsulation reference to spot bottom elevation,but this PipeInsulation I use element.reference get wrong offset reference。

Hi
here is a workaround building a “custom Reference Stable Representation” to get the bottom line reference
SpotDimensionTest

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Plumbing import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

def createSpotBottom3(pipe):
	global lstPara
	lstspot = []
	lstinsulationId = InsulationLiningBase.GetInsulationIds(doc,pipe.Id)
	if lstinsulationId:
		insulation = doc.GetElement(lstinsulationId[0])
		refStable = Reference(insulation).ConvertToStableRepresentation(doc)
		refToDim = Reference.ParseFromStableRepresentation(doc, refStable +":9:LINEAR")
		curve = insulation.Location.Curve 
	else:
		refStable = Reference(pipe).ConvertToStableRepresentation(doc)
		refToDim = Reference.ParseFromStableRepresentation(doc, refStable +":17:LINEAR")
		curve = pipe.Location.Curve 
	for p in lstPara:	
		origin = curve.Evaluate(p, True)
		bend = origin + XYZ(2,2,-2)
		end = bend + XYZ(4,0,0)
		spot = doc.Create.NewSpotElevation(	doc.ActiveView,	refToDim, origin, bend, end, origin, True)
		lstspot.append(spot)		
	return lstspot				

toList = lambda x : x if hasattr(x, '__iter__') else [x]
lstelems = toList(UnwrapElement(IN[0]))
lstPara = IN[1]
TransactionManager.Instance.EnsureInTransaction(doc)
outSpot = []
for e in lstelems:
	if isinstance(e, Pipe):
		outSpot.append(createSpotBottom3(e))		

TransactionManager.Instance.TransactionTaskDone()	
OUT = 	outSpot

Note:

  • trick to find the index Reference with Revit Lookup

  • article about Reference Stable Representation
2 Likes

Thanks for your assistance in this problem so much, how kind you are to help me.