有兴趣尝试最新版CAD .NET v14吗即下载试用版吧:
CAD .NET v14最新版下载>>>
- 启动新的Windows应用程序项目。
- 将项目保存到任何目录,例如:c: Users {UserName} Documents CAD Import .NET 11 demo_sources MyDemo。
- 将CADImport.dll文件复制到Debug目录,例如:c: Users {UserName} Documents CAD Import .NET 11 demo_sources MyDemo WindowsApplication1 WindowsApplication1 bin Debug CADImport.dll。
-
在MS Studio中添加对CADImport.dll的引用:视图>解决方案资源管理器>引用>右键单击>添加引用>浏览> c: Users {UserName} Documents CAD Import .NET 11 demo_sources MyDemo WindowsApplication1 WindowsApplication1 bin Debug CADImport.dll或文件CADImport.dll的路径>确定。
请检查是否在“参考”部分中看到CADImport,如下图所示:
-
打开代码(Solution Explorer> Form1.cs>查看代码)并添加CADImport命名空间:
.. using System.Windows.Forms; using CADImport; ..
-
创建一个新的CADImage类实例,并使用以下代码加载CAD文件:
.. public partial class Form1 : Form { CADImage cadImage; public Form1() { InitializeComponent(); string path = @"c:CADSoftTools.dxf"; cadImage = CADImage.CreateImageByExtension(path); cadImage.LoadFromFile(path); } }
请注意,必须完全使用CADImage.CreateImageByExtension方法创建正确的类的对象。
-
打开代码(Solution Explorer> Form1.cs>查看代码)并添加CADImport命名空间:
.. using System.Windows.Forms; using CADImport; ..
-
在“表单属性”(“视图”>“属性”窗口)中,选择“事件”>“绘画”。 在此处双击并编写以下代码,以将CAD图像绘制到宽度为500像素的表单上。
private void Form1_Paint(object sender, PaintEventArgs e) { if (cadImage != null) { RectangleF R; R = new RectangleF(0, 0, 500, 500); R.Height = (float) (R.Width * cadImage.Extents.Height /cadImage.Extents.Width); // width of image is 500, height depends on height/width of the drawing cadImage.Draw(e.Graphics, R); } }
是CADSoftTools厂商正式合作商,如果您有任何疑问或需求,请随时联系客服,我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!