批量获取图形视图中心坐标 - 精华帖集合
www.dimcax.com
批量获取图形视图中心坐标
如何用c#批量打开图形,然后最大化视图,最后获取其视图的中心坐标,这个问题一直困扰着.经过两天的研究及在忽悠悠\卢老大\才鸟的帮助下,终于修得正果 .
现在将代码及解决方案上传,望能帮助有需要的朋友.
lzx838
editor ed = autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument.editor;
documentcollection docs = autodesk.autocad.applicationservices.application.documentmanager;
//获取指定目录下的所有dwg文件
arraylist filelist = class1.lzxgetallfiles(@"e:\复件 成果分幅图");
int i = 0;
//遍历每一个dwg文件
foreach (string filestring in filelist)
{
//假如当前文档为空时,则新建文档.
if (autodesk.autocad.applicationservices.application.documentmanager.count == 0)
{
autodesk.autocad.applicationservices.application.documentmanager.add("acad.dwt");
}
//打开dwg文件
document doc = docs.open(filestring, true);
//设置当前的活动文档为新打开的dwg文件
if (!doc.isactive)
autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument = doc;
//最大化图形
autodesk.autocad.internal.utils.zoomobjects(true);
//根据数据库更新平面视口
doc.editor.updatetiledviewportsfromdatabase();
//获取视图中心坐标
viewtablerecord curvtr = doc.editor.getcurrentview();
//显示获取的坐标值
messagebox.show("x:" + curvtr.centerpoint.x.tostring("0.0000") + " y:" + curvtr.centerpoint.y.tostring("0.0000"));
i++;
//文件保存及关闭
doc.database.saveas("e:\\复件 成果分幅图\\新建文件夹\\" + i.tostring() + ".dwg", dwgversion.current);
doc.closeanddiscard();
}
复制代码
继续研究学习cad二次开发,从中寻觅人生乐趣!
lzx838
vs 下载次数: 12
阅读权限: 15
昨天 09:49 am
继续研究学习cad二次开发,从中寻觅人生乐趣!
,加精了
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。