几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(VB.NET/C#) (http://www.dimcax.com/hust/forumdisplay.php?f=176)
-   -   【转帖】[kean]使用.net获取autocad活动图形的完整路径 - 精华帖集合 (http://www.dimcax.com/hust/showthread.php?t=14074)

yang686526 2009-04-29 04:56 PM

【转帖】[kean]使用.net获取autocad活动图形的完整路径 - 精华帖集合
 
[kean]使用.net获取autocad活动图形的完整路径 - 精华帖集合
www.dimcax.com
[kean]使用.net获取autocad活动图形的完整路径
,
using autodesk.autocad.runtime;
using autodesk.autocad.applicationservices;
using autodesk.autocad.databaseservices;
namespace pathtest
{
public class commands
{
[commandmethod("th")]
public void drawingpath()
{
document doc =
application.documentmanager.mdiactivedocument;
hostapplicationservices hs =
hostapplicationservices.current;
string path =
hs.findfile(
doc.name,
doc.database,
findfilehint.default
);
doc.editor.writemessage(
"\nfile was found in: " + path
);
}
}
}
复制代码
我认为以上方法并不好,有时候得到不可预期的结果 application.getsystemvariable("dwgprefix").tostring(); 更好点
不错啊。这个系统变量还是第一次见呢。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
呵呵以前做lisp用过!
应该这样也可以
dim temdoc as document=application.documentmanager.mdiactivedocument dim db as database = temdoc.database dim filename as string=db.filename 就能得到当前活动图形的全路径了


所有的时间均为北京时间。 现在的时间是 12:57 PM.