Exemplo n.º 1
0
        private static string ToleranceValueToString(ToleranceValue tolerance)
        {
            StringBuilder value = new StringBuilder();

            value.Append("%%v");

            if (tolerance != null)
            {
                if (tolerance.ShowDiameterSymbol)
                {
                    value.Append("{\\Fgdt;n}");
                }
                value.Append(tolerance.Value);
                switch (tolerance.MaterialCondition)
                {
                case ToleranceMaterialCondition.None:
                    break;

                case ToleranceMaterialCondition.Maximum:
                    value.Append("{\\Fgdt;m}");
                    break;

                case ToleranceMaterialCondition.Least:
                    value.Append("{\\Fgdt;l}");
                    break;

                case ToleranceMaterialCondition.Regardless:
                    value.Append("{\\Fgdt;s}");
                    break;
                }
            }

            return(value.ToString());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <c>ToleranceEntry</c> class.
 /// </summary>
 public ToleranceEntry()
 {
     this.geometricSymbol = ToleranceGeometricSymbol.None;
     this.tolerance1      = null;
     this.tolerance2      = null;
     this.datum1          = null;
     this.datum2          = null;
     this.datum3          = null;
 }
 /// <summary>
 /// Initializes a new instance of the <c>ToleranceEntry</c> class.
 /// </summary>
 public ToleranceEntry()
 {
     this.geometricSymbol = ToleranceGeometricSymbol.None;
     this.tolerance1 = null;
     this.tolerance2 = null;
     this.datum1 = null;
     this.datum2 = null;
     this.datum3 = null;
 }
Exemplo n.º 4
0
        private static ToleranceValue ParseToleranceValue(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return(null);
            }

            bool          hasDiameterSymbol = false;
            StringBuilder value             = new StringBuilder();
            ToleranceMaterialCondition mat  = ToleranceMaterialCondition.None;

            CharEnumerator chars = s.GetEnumerator();

            while (chars.MoveNext())
            {
                char token = chars.Current;
                if (token == '{')
                {
                    char symbol = Symbol(chars);
                    if (symbol == 'n')
                    {
                        hasDiameterSymbol = true;
                    }
                    else
                    {
                        mat = ParseMaterialCondition(symbol);
                    }
                }
                else
                {
                    value.Append(token);
                }
            }

            ToleranceValue t = new ToleranceValue
            {
                ShowDiameterSymbol = hasDiameterSymbol,
                Value             = value.ToString(),
                MaterialCondition = mat
            };

            return(t);
        }
Exemplo n.º 5
0
        private static string ToleranceValueToString(ToleranceValue tolerance)
        {
            StringBuilder value = new StringBuilder();
            value.Append("%%v");

            if (tolerance != null)
            {
                if (tolerance.ShowDiameterSymbol)
                    value.Append("{\\Fgdt;n}");
                value.Append(tolerance.Value);
                switch (tolerance.MaterialCondition)
                {
                    case ToleranceMaterialCondition.None:
                        break;
                    case ToleranceMaterialCondition.Maximum:
                        value.Append("{\\Fgdt;m}");
                        break;
                    case ToleranceMaterialCondition.Least:
                        value.Append("{\\Fgdt;l}");
                        break;
                    case ToleranceMaterialCondition.Regardless:
                        value.Append("{\\Fgdt;s}");
                        break;
                }
            }

            return value.ToString();
        }
Exemplo n.º 6
0
        private static ToleranceValue ParseToleranceValue(string s)
        {
            if (string.IsNullOrEmpty(s))
                return null;

            bool hasDiameterSymbol = false;
            StringBuilder value = new StringBuilder();
            ToleranceMaterialCondition mat = ToleranceMaterialCondition.None;

            CharEnumerator chars = s.GetEnumerator();
            while (chars.MoveNext())
            {
                char token = chars.Current;
                if (token == '{')
                {
                    char symbol = Symbol(chars);
                    if (symbol == 'n')
                        hasDiameterSymbol = true;
                    else
                        mat = ParseMaterialCondition(symbol);
                }
                else
                {
                    value.Append(token);
                }
            }

            ToleranceValue t = new ToleranceValue
            {
                ShowDiameterSymbol = hasDiameterSymbol,
                Value = value.ToString(),
                MaterialCondition = mat
            };

            return t;
        }
Exemplo n.º 7
0
        private static ToleranceEntry ParseToleranceEntry(string line)
        {
            string[] values = Regex.Split(line, "%%v");

            ToleranceGeometricSymbol geom = ToleranceGeometricSymbol.None;
            ToleranceValue           t1   = null;
            ToleranceValue           t2   = null;
            DatumReferenceValue      d1   = null;
            DatumReferenceValue      d2   = null;
            DatumReferenceValue      d3   = null;

            if (!string.IsNullOrEmpty(values[0]))
            {
                if (values[0].StartsWith("{"))
                {
                    // geometric symbol
                    CharEnumerator chars  = values[0].GetEnumerator();
                    char           symbol = Symbol(chars);
                    geom = ParseGeometricSymbol(symbol);
                }
            }

            for (int i = 1; i < values.Length; i++)
            {
                string value = values[i];

                switch (i)
                {
                case 1:
                    t1 = ParseToleranceValue(value);
                    break;

                case 2:
                    t2 = ParseToleranceValue(value);
                    break;

                case 3:
                    d1 = ParseDatumReferenceValue(value);
                    break;

                case 4:
                    d2 = ParseDatumReferenceValue(value);
                    break;

                case 5:
                    d3 = ParseDatumReferenceValue(value);
                    break;

                default:
                    throw new FormatException("The tolerance string representation is not well formatted");
                }
            }

            ToleranceEntry t = new ToleranceEntry
            {
                GeometricSymbol = geom,
                Tolerance1      = t1,
                Tolerance2      = t2,
                Datum1          = d1,
                Datum2          = d2,
                Datum3          = d3
            };

            return(t);
        }