Creat dimension rebar


I want creat dimension of rebar.
Script example:

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference("System")
from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument

rebar = UnwrapElement(IN[0])
view = doc.ActiveView 
#####	
def creatdimension(view,linedb,refs):
	references = ReferenceArray()
	for ref in refs:
		references.Append(ref)
	TransactionManager.Instance.EnsureInTransaction(doc)
	dim = doc.Create.NewDimension(view,linedb,references)
	TransactionManager.Instance.TransactionTaskDone()
	return dim

opt = Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True
for line in rebar.get_Geometry(opt).GetEnumerator():
	lineout = line
ref1 = lineout.GetEndPointReference(0)
ref2 = lineout.GetEndPointReference(1)
###
linedim = rebar.GetCenterlineCurves(True,True,True,MultiplanarOption.IncludeOnlyPlanarCurves,0)
for l in linedim:
	linedim1 = l
###
shitf = UnitUtils.ConvertToInternalUnits(-200, DisplayUnitType.DUT_MILLIMETERS)
vec = shitf*XYZ(0,0,1)
transform = Transform.CreateTranslation(vec)
linedim2 = linedim1.CreateTransformed(transform)
###
references = ReferenceArray()
references.Append(ref1)
references.Append(ref2)

TransactionManager.Instance.EnsureInTransaction(doc)
dim = doc.Create.NewDimension(view,linedim2,references)
TransactionManager.Instance.TransactionTaskDone()

OUT = dim

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 55, in
Exception: The references are not geometric references.
Parameter name: references

help