Esempio n. 1
0
        public static void FromCutlistPlusCSV(string filePath, out PartList parts, out BoardList boards)
        {
            CsvFileDescription inputFileDescription = new CsvFileDescription
            {
                SeparatorChar               = ',',
                FirstLineHasColumnNames     = false,
                EnforceCsvColumnAttribute   = true,
                UseFieldIndexForReadingData = true
            };
            CsvContext cc = new CsvContext();

            IEnumerable <CutListPlusCSVRecord> records = new List <CutListPlusCSVRecord>(
                cc.Read <CutListPlusCSVRecord>(filePath, inputFileDescription));

            parts  = new PartList();
            boards = new BoardList();
            foreach (var iline in records.Where(t => t.PartNumber != "Part #"))
            {
                if (iline.MaterialName == "Stock")
                {
                    boards.Append(new BoardNode(iline.PartName, double.Parse(iline.Length.Replace("mm", "")), double.Parse(iline.Width.Replace("mm", ""))));
                }
                else
                {
                    parts.Append(new PartNode(iline.PartName, double.Parse(iline.Length.Replace("mm", "")), double.Parse(iline.Width.Replace("mm", ""))));
                }
            }
        }
Esempio n. 2
0
        internal static void FromCSV(string path, out PartList parts, out BoardList boards)
        {
            CsvFileDescription inputFileDescription = new CsvFileDescription
            {
                SeparatorChar               = ',',
                FirstLineHasColumnNames     = false,
                EnforceCsvColumnAttribute   = true,
                UseFieldIndexForReadingData = true
            };
            CsvContext cc = new CsvContext();

            IEnumerable <CSVRecord> records = new List <CSVRecord>(
                cc.Read <CSVRecord>(path, inputFileDescription));

            parts  = new PartList();
            boards = new BoardList();
            foreach (var iline in records.Where(t => !t.ItemType.StartsWith("#")))
            {
                if (iline.ItemType.ToLower() == "board")
                {
                    boards.Append(new BoardNode(iline.PartID, double.Parse(iline.Length), double.Parse(iline.Width)));
                }
                else
                {
                    parts.Append(new PartNode(iline.PartID, double.Parse(iline.Length), double.Parse(iline.Width)));
                }
            }
        }