RevitLookup.Test.SDKSamples.CreateSheet.Views.CalculateDistance C# (CSharp) Method

CalculateDistance() private method

Calculate the appropriate distance between the views lay on the sheet.
private CalculateDistance ( BoundingBoxUV bBox, int amount, double &x, double &y ) : void
bBox BoundingBoxUV The outline of sheet.
amount int Amount of views.
x double Distance in x axis between each view
y double Distance in y axis between each view
return void
        private void CalculateDistance(BoundingBoxUV bBox, int amount, ref double x, ref double y)
        {
            double xLength = (bBox.Max.U - bBox.Min.U) * (1 - TITLEBAR);
            double yLength = (bBox.Max.V - bBox.Min.V);

            //calculate appropriate rows numbers.
            double result = Math.Sqrt(amount);

            while (0 < (result - (int)result)) {
                amount = amount + 1;
                result = Math.Sqrt(amount);
            }
            m_rows = result;
            double area = xLength * yLength / amount;

            //calculate appropriate distance between the views.
            if (bBox.Max.U > bBox.Max.V) {
                x = Math.Sqrt(area / GOLDENSECTION);
                y = GOLDENSECTION * x;
            }
            else {
                y = Math.Sqrt(area / GOLDENSECTION);
                x = GOLDENSECTION * y;
            }
        }