We want to create a dimension between a vertical pipe (same direction with the view normal) and a grid in a plan view. But we failed to do so both in Revit 2016 and 2017. Helps are really welcome.
In 2016, we can get the point reference of the vertical pipe (both ends), but failed to make the dimension correctly (even the AddDimension function returns and the result does have an valid ElementId, but it's invisible).
In 2017, we cann't get the point reference anyone (it's always null).
The get point reference code as following:
Point ptr = null;
Options opt = new Options();
opt.ComputeReferences = true;
opt.IncludeNonVisibleObjects = true;
opt.View = doc.ActiveView;
foreach (GeometryObject obj in elem.get_Geometry(opt))
{
if (obj is Point) {
Point pt = obj as Point;
if (pt.Reference != null) {
if (ptr == null) {
ptr = pt;
} else if (ptr.Coord.Z < pt.Coord.Z) {
ptr = pt;
}
}
}
}