Beispiel #1
0
        private void Vornehmen_Click(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(werkzeug_neu) && height_neu != 0 && width_neu != 0 && depth_neu != 0 && werkzeug_neu.Length > 4)
                {
                    newPt = new netDxf.Entities.Point(height_neu, width_neu, depth_neu);
                    List <netDxf.Entities.Point> neuList = Doc.Points.ToList();
                    workpiece neuWorkpiece = new workpiece();
                    neuWorkpiece.depth        = depth_neu;
                    neuWorkpiece.height       = height_neu;
                    neuWorkpiece.width        = width_neu;
                    neuWorkpiece.werkzeugName = werkzeug_neu;
                    foreach (netDxf.Entities.Point item in neuList)
                    {
                        Doc.RemoveEntity(item);
                    }



                    DXF_Management.DXF_Writer.JoinToDxF(PFAD, ref Doc, neuWorkpiece);
                    MessageBox.Show("Erfolgreich vorgenommen!", "Arbeitseigenschaften Veränderung", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBox.Show("Falsche Eingabe \n Bitte überprüfen Sie Ihre Eingaben!", "Arbeitseigenschaften Veränderung", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, "Arbeitseigenschaften Veränderung", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Beispiel #2
0
        void fixDXF(string[] files)
        {
            foreach (string file in files)
            {
                //open in the version that supports saving and opening R12, do all the work in latest version, then save as R12

                string fileName     = Path.GetFileName(file);
                string tempFileName = file.Substring(0, file.Length - fileName.Length) + "TMP.DXF";
                Console.WriteLine(fileName.Substring(fileName.Length - 4).ToLower());
                if (fileName == null || fileName.Substring(fileName.Length - 4).ToLower() != ".dxf")
                {
                    continue;
                }

                //open as R12 and save in different format for newer library
                R12.netDxf.DxfDocument inputDxf = new R12.netDxf.DxfDocument();
                inputDxf.Load(file);

                inputDxf.Save(tempFileName, R12.netDxf.Header.DxfVersion.AutoCad2010);

                //open in new library and do all the editing
                DxfDocument workingDxf = DxfDocument.Load(tempFileName);

                Arc[]        toRemove = new Arc[workingDxf.Arcs.Count()];
                LwPolyline[] toAdd    = new LwPolyline[workingDxf.Arcs.Count()];
                int          count    = 0;
                foreach (Arc i in workingDxf.Arcs)
                {
                    toRemove[count] = i;
                    toAdd[count]    = i.ToPolyline(1000);
                    count++;
                }

                for (int i = 0; i < toRemove.Length; i++)
                {
                    workingDxf.RemoveEntity(toRemove[i]);
                    workingDxf.AddEntity(toAdd[i]);
                }

                workingDxf.Save(tempFileName);

                //open it back in R12 library and save as R12
                R12.netDxf.DxfDocument outputDxf = new R12.netDxf.DxfDocument();
                outputDxf.Load(tempFileName);

                outputDxf.Save(file.Insert(file.Length - 4, "_FIXED"), R12.netDxf.Header.DxfVersion.AutoCad12);
                File.Delete(tempFileName);
            }
        }