Esempio n. 1
0
 public double DoubleValue()
 {
     return(DXFUtils.StringToDouble(this.FValue));
 }
Esempio n. 2
0
        private static void AddLineTypeDefinitionToExport(ref StringBuilder _sb, string _name, string _description, string _pattern = "")
        {
            if (_sb == null || string.IsNullOrEmpty(_name))
            {
                return;
            }
            string descr = (string.IsNullOrEmpty(_description)) ? "Solid line" : _description;

            _sb.AppendLine(((int)DXFSpecSaveCodes.ENTITY_TYPE).ToString());          // 0
            _sb.AppendLine(DXFUtils.LTYPE);                                          // LTYPE
            _sb.AppendLine(((int)DXFSpecSaveCodes.SUBCLASS_MARKER).ToString());      // 100
            _sb.AppendLine("AcDbSymbolTableRecord");
            _sb.AppendLine(((int)DXFSpecSaveCodes.SUBCLASS_MARKER).ToString());      // 100
            _sb.AppendLine("AcDbLinetypeTableRecord");

            _sb.AppendLine(((int)EntitySaveCode.ENTITY_NAME).ToString());            // 2
            _sb.AppendLine(_name);                                                   // ENTITY_NAME
            _sb.AppendLine("70");                                                    // 70 flag for XREFS and EDITING MARKER in AutoCAD
            _sb.AppendLine("0");                                                     // set no flags
            _sb.AppendLine("3");                                                     // 3 descriptive text for the linetype
            _sb.AppendLine(descr);                                                   // description
            _sb.AppendLine("72");                                                    // alignment code; value is always 65, the ASCII code for A
            _sb.AppendLine("65");                                                    // A

            // analyse the pattern
            double[] pattern_element_length;
            double   total_pattern_length = 0.0;
            int      nr_pattern_elements  = 0;

            string[] parts = _pattern.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            if (parts != null && parts.Length > 1)
            {
                nr_pattern_elements    = parts.Length;
                pattern_element_length = new double[nr_pattern_elements];
                int c = 0;
                foreach (string x in parts)
                {
                    pattern_element_length[c] = DXFUtils.StringToDouble(x);
                    c++;
                }
                total_pattern_length = pattern_element_length.Select(x => Math.Abs(x)).Sum();

                _sb.AppendLine("73");                                                    // the number of linetype elements
                _sb.AppendLine(nr_pattern_elements.ToString());
                _sb.AppendLine("40");                                                    // total pattern length
                _sb.AppendLine(DXFUtils.ValueToString(total_pattern_length, "F15"));

                foreach (double d in pattern_element_length)
                {
                    _sb.AppendLine("49");                                                    // dash, dot or space length
                    _sb.AppendLine(DXFUtils.ValueToString(d, "F15"));
                    //_sb.AppendLine("74");                                                    // line element type flags (AutoCAD dosen't recognize it)
                    //_sb.AppendLine("0");
                }
            }
            else
            {
                _sb.AppendLine("73");                                                    // the number of linetype elements
                _sb.AppendLine("0");
                _sb.AppendLine("40");                                                    // total pattern length
                _sb.AppendLine("0.0");
            }
        }