AnsweredAssumed Answered

Horizontal or Vertical Dimension?

Question asked by William Cruz on Nov 21, 2016
Latest reply on Nov 28, 2016 by John Alexander

I'm trying to figure out if a dimension is Horizontal or Vertical. The C# code below doesn't always work.

          internal bool Compare(double v1, double v2)
        {//https://cloud.centralinnovation.com.au/sharpcode/index?article=Get-the-Dimensions-Orientation
            try
            {
                const double TOL = 0.0000000001;

                return Math.Abs(Math.Abs(v1) - Math.Abs(v2)) < TOL ? true : false;
            }
            catch (Exception ex)
            {
                LogIt.LogError(ex);
                return false;
            }
        }

 

To use the above code:

                                   DisplayDimension dimDispDim1 = (DisplayDimension)objCurrent;
                                   Dimension dimTemp;
                                   dimTemp = dimDispDim1.GetDimension2(0);
                                   double[] dimdir = dimTemp.DimensionLineDirection.ArrayData;

                                   if (Compare(dimdir[0], 1) && Compare(dimdir[1], 0) && Compare(dimdir[2], 0))
                                   {
                                       _IsItHorizonal = true;
                                   }
                                   else if (Compare(dimdir[0], 0) && Compare(dimdir[1], 1) && Compare(dimdir[2], 0))
                                   {
                                       _IsItHorizonal = false;
}

 

Outcomes