Got a glitch in Setting a parameter value of a rebar. Actually i set some values for the rebar's parameter and copied that element and placed in a regular intervals but I found an anomaly in that. 1st rebar while placing becomes odd

TransactionManager.Instance.EnsureInTransaction(doc)

parameterA = items[0].LookupParameter("A")
valueOfA = UnitUtils.ConvertToInternalUnits(A,dut)
	
parameterB = items[0].LookupParameter("B")
valueOfB = UnitUtils.ConvertToInternalUnits(B,dut)

parameterC = items[0].LookupParameter("C")
valueOfC = UnitUtils.ConvertToInternalUnits(C,dut)

parameterD = items[0].LookupParameter("D")
valueOfD = UnitUtils.ConvertToInternalUnits(D,dut)


parameterA.Set(valueOfA)
	
parameterB.Set(valueOfB)
	
parameterC.Set(valueOfC)
	
parameterD.Set(valueOfD)

copiedElements[len(copiedElements) - 1] =  ElementTransformUtils.CopyElements(doc,itemlist,listOfPastePoints[0])

for xyz in range(0, (len(listOfPastePoints) - 1), 1) :
	
	copiedElements[xyz] = ElementTransformUtils.CopyElements(doc,itemlist,listOfPastePoints[xyz])

doc.Delete(copiedElements[len(copiedElements) - 1])
TransactionManager.Instance.TransactionTaskDone() 

image
The above Image is Output of the above code.

If i just commented below two lines in the above code,

copiedElements[len(copiedElements) - 1] =  ElementTransformUtils.CopyElements(doc,itemlist,listOfPastePoints[0])
doc.Delete(copiedElements[len(copiedElements) - 1])

I am getting Output like the below image
image

if I remove setting value of C, then i can get perfect output like first Image

parameterC.Set(valueOfC) 
""" If i comment this line, I dont need to paste the first rebar two times and delete the odd. """

The problem is the first pasting element becomes odd. So i pasted two rebars at the same point and deleted the odd rebar. My method works but I dont know why this anomaly is happening. Let me know if there is any mistakes in my code or corrections required or If any aditional information required. Thank You.