示例#1
0
        public void LoadXml(string v)
        {
            var d   = XDocument.Load(v);
            var f   = d.Descendants().First();
            var gap = int.Parse(f.Attribute("gap").Value);

            SvgNest.Config.spacing = gap;

            foreach (var item in d.Descendants("sheet"))
            {
                int src = GetNextSheetSource();
                var cnt = int.Parse(item.Attribute("count").Value);
                var ww  = int.Parse(item.Attribute("width").Value);
                var hh  = int.Parse(item.Attribute("height").Value);

                for (int i = 0; i < cnt; i++)
                {
                    AddSheet(ww, hh, src);
                }
            }
            foreach (var item in d.Descendants("part"))
            {
                var cnt  = int.Parse(item.Attribute("count").Value);
                var path = item.Attribute("path").Value;
                var r    = SvgParser.LoadSvg(path);
                var src  = GetNextSource();

                for (int i = 0; i < cnt; i++)
                {
                    ImportFromRawDetail(r, src);
                }
            }
        }
示例#2
0
        public void LoadInputData(string path, int count)
        {
            var dir = new DirectoryInfo(path);

            foreach (var item in dir.GetFiles("*.svg"))
            {
                try
                {
                    var src = GetNextSource();
                    for (int i = 0; i < count; i++)
                    {
                        ImportFromRawDetail(SvgParser.LoadSvg(item.FullName), src);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error loading " + item.FullName + ". skip");
                }
            }
        }
示例#3
0
        public void LoadXml(string v)
        {
            var d   = XDocument.Load(v);
            var f   = d.Descendants().First();
            var gap = int.Parse(f.Attribute("gap").Value);

            SvgNest.Config.Spacing = gap;

            foreach (var item in d.Descendants("sheet"))
            {
                int src = GetNextSheetSource();
                var cnt = int.Parse(item.Attribute("count").Value);
                var ww  = int.Parse(item.Attribute("width").Value);
                var hh  = int.Parse(item.Attribute("height").Value);

                for (int i = 0; i < cnt; i++)
                {
                    AddSheet(ww, hh, src);
                }
            }
            foreach (var item in d.Descendants("parts"))
            {
                var cnt  = int.Parse(item.Attribute("count").Value);
                var dir  = item.Attribute("dir").Value;
                var dxfs = Directory.GetFiles(dir, "*.dxf");
                var svgs = Directory.GetFiles(dir, "*.svg");

                foreach (var dxf in dxfs)
                {
                    var r   = DxfParser.loadDxf(dxf);
                    var src = GetNextSource();
                    for (int i = 0; i < cnt; i++)
                    {
                        ImportFromRawDetail(r, src);
                    }
                }

                foreach (var svg in svgs)
                {
                    var r   = SvgParser.LoadSvg(svg);
                    var src = GetNextSource();
                    for (int i = 0; i < cnt; i++)
                    {
                        ImportFromRawDetail(r, src);
                    }
                }
            }
            foreach (var item in d.Descendants("part"))
            {
                var       cnt  = int.Parse(item.Attribute("count").Value);
                var       path = item.Attribute("path").Value;
                var       ext  = Path.GetExtension(path);
                RawDetail r;
                if (ext.ToLower() == ".dxf")
                {
                    r = DxfParser.loadDxf(path);
                }
                else
                {
                    r = SvgParser.LoadSvg(path);
                }

                var src = GetNextSource();
                for (int i = 0; i < cnt; i++)
                {
                    ImportFromRawDetail(r, src);
                }
            }
        }