Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

What is the difference difference between the viewport bottom left and view(crop region) bottom corner

FrankHolidaytoiling
Advocate

What is the difference difference between the viewport bottom left and view(crop region) bottom corner

FrankHolidaytoiling
Advocate
Advocate

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. 

FrankHolidaytoiling_0-1721807276010.png

 

 

 

        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;
        }

 

 

 

0 Likes
Reply
Accepted solutions (1)
337 Views
2 Replies
Replies (2)

jeremy_tammik
Autodesk
Autodesk
Accepted solution

Does this help?

  

  

I found it by searching the Revit online help for "viewport crop" and filtering for the information category "Developer's Documentation":

  

  

There are many other suggested solutions there for you to peruse at will.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

FrankHolidaytoiling
Advocate
Advocate

Wow, me and a colleague should find this useful elsewhere if it doesnt solve my current problem, thanx Jeremy!

0 Likes