7 Replies Latest reply on May 17, 2018 8:20 AM by John Alexander

    DimensionLineDirection Ordinate Dimension

    John Alexander

      I'm getting a weird result for DimensionLineDirection of an ordinate dimension.

       

      For the basic dimension, the dimension line direction tells me the direction (in model coordinates?) of the dimension.

       

       

      If I look at the model, this dimension is aligned with the Z-axis. This agrees with my understanding.

       

       

      However, for the ordinate dimension, I get the following.

       

       

       

       

      Basic Dimension:

      [0,0,1]

       

      Ordinate Dimension:

      [1,0,0]

       

      Actual direction in model coordinates:

      [0,0,1]

       

       

      My first guess was that the ordinate dimension's DimensionLineDirection is using the (Visible) extension line rather than the (Invisible) vector along which the dimension is measuring. However, if this were the case, it wouldn't be reported in the x-direction. If it was in drawing-coordinates, that line would be along the Y axis, if it were in model coordinates, that line would be along the Y axis still.

       

      Does anyone have a guess?

       

      Thanks,

      John Alexander

        • Re: DimensionLineDirection Ordinate Dimension
          Amen Allah Jlili

          Just a shot in the dark: Is this referenced document in the drawing view a part or an assembly? If it's an assembly, shouldn't you be considering the component's transform as well?

            • Re: DimensionLineDirection Ordinate Dimension
              John Alexander

              It is a drawing of a part.

               

              I'm actually not transforming the DimensionLineDirection, my assumption has been that it is expressed with respect to the part document's coordinate system and so I've just been building my analysis around that coordinate system. So far this works fine for basic dimensions. However, when I dimension the exact same span with an Ordinate versus a Basic dimension, the direction is different.

            • Re: DimensionLineDirection Ordinate Dimension
              John Alexander

              Some more data points. I tried grabbing the ReferencePoints properties out of these dimensions.

               

              2012 SOLIDWORKS API Help - ReferencePoints Property (IDimension)

               

              My assumption follows that the value of the dimension (0.025 in this case) would equal the DimensionLineDirection.Dot(RefP1-RefP0). That is, the vector between the Reference Points projected onto the DimensionLineDirection should equal the value of the dimension.

               

              For basic dimensions, this seems to be the case. For ordinate dimensions, I have no idea what is going on. the ReferencePoint coordinates aren't even remotely similar.

               

               

              The first set of numbers is the ordinate dimension, the second set is from the basic dimension. These are the same pair of dimensions as described in the original post.

               

                       public static bool DimensionIsAlignedWithHoleInstance(Tuple<DisplayDimension, View> positionalDimension, HoleInstance holeInstance, int direction){

                           Dimension dimension = positionalDimension.Item1.GetDimension2(0);

                          

                           object[] oReferencePoints = (object[])dimension.ReferencePoints;

                          

                           MathPoint point0 = (MathPoint)(oReferencePoints[0]);

                           MathPoint point1 = (MathPoint)(oReferencePoints[1]);

                           MathVector difference = (MathVector)(point1.Subtract((object)point0));

                           MathVector dimensionDirection = (MathVector)dimension.DimensionLineDirection;

                          

                           Console.WriteLine("P0:  " + ((double[])point0.ArrayData)[0] + ", " + ((double[])point0.ArrayData)[1] + ", " + ((double[])point0.ArrayData)[2]);

                           Console.WriteLine("P1:  " + ((double[])point1.ArrayData)[0] + ", " + ((double[])point1.ArrayData)[1] + ", " + ((double[])point1.ArrayData)[2]);

                          

                           Console.WriteLine("Difference: " + ((double[])difference.ArrayData)[0] + ", " + ((double[])difference.ArrayData)[1] + ", " + ((double[])difference.ArrayData)[2]);

                           Console.WriteLine("Direction:  " + ((double[])dimensionDirection.ArrayData)[0] + ", " + ((double[])dimensionDirection.ArrayData)[1] + ", " + ((double[])dimensionDirection.ArrayData)[2]);

                           Console.WriteLine("Value: " + (double)difference.Dot((object)dimensionDirection));

                           Console.WriteLine("");

                       }

              • Re: DimensionLineDirection Ordinate Dimension
                John Alexander

                Okay, I think I've figured it out.

                 

                The ordinate dimension reports its DimensionLineDirection with respect to the drawing coordinate system. The Basic dimension reports with respect to the model document. I just transform the direction vector whenever the DisplayDimension is an ordinate.

                 

                public static bool DimensionIsAlignedWithHoleInstance(Tuple<DisplayDimension, View> positionalDimension, HoleInstance holeInstance, int direction){

                             Annotation donk =(Annotation)positionalDimension.Item1.GetAnnotation();

                             donk.Select3(false, null);

                            

                             Dimension dimension = positionalDimension.Item1.GetDimension2(0);

                             MathVector dimensionDirection = (MathVector)dimension.DimensionLineDirection;

                             int duder = positionalDimension.Item1.Type2;

                             if((positionalDimension.Item1.Type2 == (int)swDimensionType_e.swHorOrdinateDimension) | (positionalDimension.Item1.Type2 == (int)swDimensionType_e.swOrdinateDimension) | (positionalDimension.Item1.Type2 == (int)swDimensionType_e.swVertOrdinateDimension)){

                                 dimensionDirection = (MathVector)((MathVector)dimensionDirection.MultiplyTransform(positionalDimension.Item2.ModelToViewTransform.Inverse())).Normalise();

                             }

                            

                             double dot = double.PositiveInfinity;

                             if(direction == 0){

                                 dot = dimensionDirection.Dot(holeInstance.collinearDirectionX0);

                             }else if(direction == 1){

                                 dot = dimensionDirection.Dot(holeInstance.collinearDirectionX1);

                             }

                            

                             return DimensionalConstraintSolver.IsEpsilonEqual(dot, 0);

                         }

                • Re: DimensionLineDirection Ordinate Dimension
                  Rubén Rodolfo Balderrama

                  Let's see:

                  The design has X Up

                  The sketch has Z Top

                  The only place where you have problems is when you send the 3D file to a third-party CAM system