Hi
I used below code to create a Dimension.
Reference refElement0 = sel.PickObject(ObjectType.Element, "selectColumn0");
Reference refElement1 = sel.PickObject(ObjectType.Element, "selectColumn1");
FamilyInstance familyInstance0 = Doc.GetElement(refElement0) as FamilyInstance;
FamilyInstance familyInstance1 = Doc.GetElement(refElement1) as FamilyInstance;
FaceArray faces0 = GetFaceArrayOfFamilyInstance(familyInstance0);
FaceArray faces1 = GetFaceArrayOfFamilyInstance(familyInstance1);
Face face0 = null;
Face face1 = null;
foreach (Face face in faces0)
{
XYZ faceNormal = GetFaceNormal(face);
if (faceNormal.IsAlmostEqualTo(new XYZ(0, -1, 0)))
{
face0 = face;
break;
}
}
foreach (Face face in faces1)
{
XYZ faceNormal = GetFaceNormal(face);
if (faceNormal.IsAlmostEqualTo(new XYZ(0, -1, 0)))
{
face1 = face;
break;
}
}
ReferenceArray refArray = new ReferenceArray();
refArray.Append(face0.Reference);
refArray.Append(face1.Reference);
using (Transaction t = new Transaction(Doc, "CreateDimension"))
{
t.Start();
LocationPoint locationPoint0 = familyInstance0.Location as LocationPoint;
LocationPoint locationPoint1 = familyInstance1.Location as LocationPoint;
Line lineDimension = Line.CreateBound(locationPoint0.Point, locationPoint1.Point);
Doc.Create.NewDimension(Doc.ActiveView, lineDimension, refArray);
t.Commit();
}
As expected,the reslut is like below:

But.. I really want is like below ..which is to create dimension based on the column center like manually createing the dimension from revit UI (can select the center line of a column). And what does this bule line represent, Face? Plane? Line?

Any idea on how to implement this? Thx!