Total bar length query in rebar container

Yes, I deleted my original post.

See if this is gets you what you need. I commented out your line item for writing the value to the total bar length parameter and added everything after the “rebars.append(rebarContainer)”. When I ran, it worked for me.

# Update container parameters.
quantityParameter = rebarContainer.get_Parameter(BuiltInParameter.REBAR_ELEM_QUANTITY_OF_BARS)
totalLengthParameter = rebarContainer.LookupParameter("Total Bar Length")
containerParameters = rebarContainer.GetParametersManager()
containerParameters.AddOverride(quantityParameter.Id, len(out_V_rebar))
#containerParameters.AddOverride(totalLengthParameter.Id, len(out_V_rebar)* sum(shared_params)*0.3048)

rebars.append(rebarContainer)

for r in rebars:
	qty = r.ItemsCount

paramlist = ["a","b","c","d","e","f","g","h","H1","H2"]
val = []
aval = []
for p in paramlist:
	for r in rebars:
		val.append(r.LookupParameter(p))
for v in val:
	aval.append(v.AsDouble()*304.8)

totallength = sum(aval) * qty * 0.3048

containerParameters.AddOverride(totalLengthParameter.Id, totallength)

EDIT
I don’t know why there is a different parameter value for you when using Revit Lookup. I tested and the values were matching for me. Maybe someone else can provide input on that if you need.

2 Likes