First get Sleeve(speciality equipment) XYZ Co-ordinates
Second we get grid intersection point nearest to sleeve and then find nearest point from sleeve on the grid
Third step we get references of sleeve and grid.
Fourth one is draw line using sleeve and grid XYZ coordinates
and then draw dimensions
XYZ sleeve_xyz = null;
Element elm = doc.GetElement(Sleeve_id.Id);
FamilyInstance fi = elm as FamilyInstance;
Autodesk.Revit.DB.Location position = elm.Location;
Autodesk.Revit.DB.LocationPoint positionPoint = position as Autodesk.Revit.DB.LocationPoint;
sleeve_xyz = positionPoint.Point;
sleeve_xyz = new XYZ(sleeve_xyz.X, sleeve_xyz.Y, 0);
Reference sleeve_ref = GetSleeveReference(fi, SpecialReferenceType.CenterLR);
Grid first_grid2 = doc.GetElement(First_Grid_elemID) as Grid;
Reference gridRef = null;
Options opt = new Options();
opt.ComputeReferences = true;
opt.IncludeNonVisibleObjects = true;
opt.View = doc.ActiveView;
foreach (GeometryObject obj in first_grid2.get_Geometry(opt))
{
if (obj is Autodesk.Revit.DB.Line)
{
Autodesk.Revit.DB.Line line = obj as Autodesk.Revit.DB.Line;
gridRef = line.Reference;
}
}
XYZ gr_point2 = new XYZ(grid_intersection_point.X, sleeve_xyz.Y, 0.000000000);
Autodesk.Revit.DB.Line line5 = null;
line5 = Autodesk.Revit.DB.Line.CreateBound(gr_point2, sleeve_xyz);
ReferenceArray refArray = new ReferenceArray();
refArray.Append(sleeve_ref);
refArray.Append(gridRef);
Dimension dim = doc.Create.NewDimension(doc.ActiveView, line5, refArray);