It’s the sequencing of things that you are not getting right. You are trying to write to elements, and place them at the same time. These tasks have to be sequenced so that you first create the element, commit it to Revit DB and then write something to its parameters. Again, try placing Transaction.End after FamilyInstance.ByPoint and before you feed it into Element.SetParameter.
LÉON LEERAAR, use Lunchbox Room Collector instead. Nate’s version provides you with the origin of the room which is more stable than finding a center.
Let’s say a room has multiple closed loops (doughnut). This makes it very difficult to find the center most point of a room with the polygon method you are using. This then results in an uneven list, which is why you are seeing inconsistencies.