Example #1
0
 /// <summary>
 /// 图形保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button5_Click(object sender, EventArgs e)
 {
     if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         try
         {
             string cadFileDir = string.Concat(System.AppDomain.CurrentDomain.BaseDirectory, "TmpFile\\");
             X2Directory.CreatDir(cadFileDir);
             string cadFilePath = string.Concat(cadFileDir, "TmpCadFile.dxf");
             X2File.CopyFile(this.saveFileDialog1.FileName, cadFilePath);
             MessageBox.Show("保存完毕!");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Example #2
0
        /// <summary>
        /// 自动绘制cad图形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            #region 暂时删除
            //DxfDocument dxf = new DxfDocument();
            //List<PolyfaceMeshVertex> vertexes = new List<PolyfaceMeshVertex>
            //                                        {
            //                                            new PolyfaceMeshVertex(0, 0, 0),
            //                                            new PolyfaceMeshVertex(10, 0, 0),
            //                                            new PolyfaceMeshVertex(10, 10, 0),
            //                                            new PolyfaceMeshVertex(5, 15, 0),
            //                                            new PolyfaceMeshVertex(0, 10, 0)
            //                                        };
            //List<PolyfaceMeshFace> faces = new List<PolyfaceMeshFace>
            //                                   {
            //                                       new PolyfaceMeshFace(new[] {1, 2, -3}),
            //                                       new PolyfaceMeshFace(new[] {-1, 3, -4}),
            //                                       new PolyfaceMeshFace(new[] {-1, 4, 5})
            //                                   };

            //PolyfaceMesh mesh = new PolyfaceMesh(vertexes, faces);
            //dxf.AddEntity(mesh);
            //dxf.Save("mesh.dxf", DxfVersion.AutoCad2000);
            #endregion

            string cadFileDir = string.Concat(System.AppDomain.CurrentDomain.BaseDirectory, "TmpFile\\");
            X2Directory.CreatDir(cadFileDir);
            string cadFilePath = string.Concat(cadFileDir, "TmpCadFile.dxf");
            if (X2File.IsExist(cadFilePath))
            {
                X2File.DeleteFile(cadFilePath);
            }

            //Polyline(cadFilePath);
            DrawLine();
            MessageBox.Show("绘制完成");
            //string newFilePath = cadFilePath;
            //if (!X2File.IsExist(newFilePath))
            //{
            //    MessageBox.Show("未找到CAD图:" + newFilePath);
            //}
        }