How to assign the family type to the face-based element using Dynamo


I have a problem in assigning the family type which is created in Revit through the Dynamo.
First, in Dynamo I have created the bounding boxes and centroid for each selected elements and later I change the bounding boxes with the the Family type that I have created in Revit. But the problem here is the assigned generative model family type is not sitting on the center of the elements in Revit. The family placement

I attach the screen shot of my pilot study.
Any thoughts would be helpful. Thanks!