利用VBA实现AutoCAD的样条曲线SPline的打断转化

来源:互联网 发布:神马打印软件 编辑:程序博客网 时间:2024/04/27 04:12

 SolidWorks、coreldraw、PS、Illustrator等矢量绘图或3D图象图形设计处理软件,在进行CAD格式输出后,转出的CAD文件都是样条曲线SPLINE线,要想转化变成LINE或PLINE线,该怎么办呢?
AutoCAD中并没有提供现成的命令去处理。
我们可以通过AutoCAD提供的二次开发工具VBA来自行解决这个问题。
用AutoCAD打开对应的cad文件,选择“工具”菜单中的“宏”—-”Visual Basic 编辑器"命令,打开VBA编辑器,将下列的代码粘贴到其中,点击运行命令,转化即可在瞬间完成。
相应程序代码命令的含义可以查阅VBA联机文档。

其他的一些方法:
1.命令行键入命令:flatten,按提示选择你要转换的样条曲线即可。
注意:flatten命令是Express扩展工具包中的命令,使用前先确认你已经安装了这个扩展工具。
(use the FLATTEN command and it will convert that spline into a polyline with arc segments.)

2.将要转换的样条曲线复制在一新图中,用“另存为”命令将图纸保存为“AutoCAD R12/L12 DXF(*.dxf)”格式,再“打开”命令选择打开刚才保存的“DXF (*.dxf)”格式文件即可。 (Save the drawing asAutocad R12/LT2 DXF. Close the drawing. Reopen the DXF file. Thischanges the spline to a polyline. Explode the polyline if needed, andyou have lots of little line segments that your CAM program can read.)

<script type="text/javascript"><!-- google_ad_client = "pub-2416224910262877";/* 468x60, 创建于 09-10-26 */google_ad_slot = "4904928216";google_ad_width = 468;google_ad_height = 60;// --></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

原创粉丝点击