- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The Viewport label offset addition to Revit API 2022, appeared to be very useful. However the offset is from the viewport which does not help consistent view title alignment as the user is only concerned with the view or the crop region boundary. If you align views you can use the crop box centre and get a delta to align, however while the user aligns views on sheets and then aligns the crop boundary they need the viewport title to align to the view bottom left corner. Below I have used a function to get the bottom left of the view as I thought I could get the offset from the label offset XYZ and the bottom of the view and then use this as a correction for the view title position however i am getting large values for what should be 3.2mm height difference on the viewsheet i get 545.5mm difference in the y plane from comparing the view bottom left and label offset value.
private static XYZ GetBottomLeftCornerPoint(View view)
{
XYZ view_X = view.RightDirection;
XYZ view_Up = view.UpDirection;
double MinUpvalue = double.MaxValue;
XYZ bottomLeft = new XYZ(0, 0, 0);
IList<CurveLoop> cLoops = view.GetCropRegionShapeManager().GetCropShape();
foreach (CurveLoop cLoop in cLoops)
{
foreach (Curve cv in cLoop)
{
IList<XYZ> points = cv.Tessellate();
if (points == null) continue;
for (int ip = 0; ip < points.Count - 1; ip++)
{
XYZ pnt = points[ip];
double UpValue = view_Up.DotProduct(pnt);
double diff = 0;
if (MinUpvalue != double.MaxValue)
diff = Math.Round(MinUpvalue - UpValue, 10);
if (MinUpvalue == double.MaxValue || diff > 0) // pnt "lower" or first point
{
MinUpvalue = UpValue;
bottomLeft = pnt;
continue;
}
if (diff == 0) // pnt on same height
{
double pntvalue = view_X.DotProduct(pnt);
double bottomvalue = view_X.DotProduct(bottomLeft);
if (Math.Round(pntvalue - bottomvalue, 10) < 0) // pnt more to left
{
bottomLeft = pnt;
}
}
}
}
}
return bottomLeft;
}
Solved! Go to Solution.