6 Replies Latest reply on Nov 28, 2016 2:54 PM by John Alexander

    Horizontal or Vertical Dimension?

    William Cruz

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