public void TEEEETTSTSTS()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
IList<Reference> reference = uidoc.Selection.PickObjects(ObjectType.Element);
Options opt = null;
opt = new Options();
opt.ComputeReferences = true;
opt.IncludeNonVisibleObjects = true;
ReferenceArray refArray = new ReferenceArray();
FamilyInstance firstEl = doc.GetElement(reference[0]) as FamilyInstance;
FamilyInstance secEl = doc.GetElement(reference[1]) as FamilyInstance;
var pts1 = (firstEl.Location as LocationPoint).Point;
var pts2 = (secEl.Location as LocationPoint).Point;
refArray.Append(GetReferenceFromFamilyInstance(firstEl,opt));
refArray.Append(GetReferenceFromFamilyInstance(secEl,opt));
Line line1 = Line.CreateBound(pts1, pts2);
using (Transaction tr = new Transaction(doc))
{
tr.Start("f");
doc.Create.NewDimension(doc.ActiveView, line1, refArray);
tr.Commit();
}