Ejemplo n.º 1
0
    public double[] getspec(NXOpen.Annotations.Dimension dim)//返回一个尺寸的名义值和上下公差,第一个值是名义值,第二个是上公差,第三个是下公差
    {
        string[] a;
        string[] b;
        double   maindim = 0;
        double   low     = 0;
        double   up      = 0;

        double[] final = { 0, 0, 0 };
        dim.GetDimensionText(out a, out b);
        maindim  = double.Parse(a[0]);
        up       = dim.UpperMetricToleranceValue;
        low      = dim.LowerMetricToleranceValue;
        final[0] = maindim;
        final[1] = up;
        final[2] = low;
        return(final);
    }
Ejemplo n.º 2
0
    // private static UI theUI = null;



    public static string GetDimensionValue(NXOpen.Annotations.Dimension dimension)
    {
        try
        {
            string[] mainTextLines;
            string[] dualTextLines;
            dimension.GetDimensionText(out mainTextLines, out dualTextLines);
            if (mainTextLines.Length > 0)
            {
                //这里可能包含特殊字符,从中得到连续数字
                string num = GetNumberFromString(mainTextLines[0]);
                return(num);
            }
            else
            {
                return(null);
            }
        }
        catch    /* (System.Exception ex)*/
        {
            throw new Exception("读取尺寸值失败,请手动指定尺寸值");
        }
    }