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


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(VB.NET/C#)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-19, 10:37 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】c# 显示进度条的原代码

c# 显示进度条的原代码
www.dimcax.com
c# 显示进度条的原代码
using autodesk.autocad.runtime; using system.runtime.interopservices; using system.windows.forms; namespace progressmetertest { public class cmds { [dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeter@@yahpb_whh@z" //this should work for autocad private static extern int acedsetstatusbarprogressmeter( string label, int minpos, int maxpos ); [dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeterpos@@yahh@z" )] private static extern int acedsetstatusbarprogressmeterpos(int pos); [dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedrestorestatusbar@@yaxxz" )] private static extern int acedrestorestatusbar(); [commandmethod("pb")] public void progressbar() { acedsetstatusbarprogressmeter("testing progress bar", 0, 100); for (int i = 0; i <= 100; i++) { for (int j = 0; j <= 10; j++) { system.threading.thread.sleep(1); acedsetstatusbarprogressmeterpos(i); // this allows autocad to repaint application.doevents(); } } acedrestorestatusbar(); } } }
dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeterpos@@yahh@z" 这一句 什么意思是调用 dll 文件吗? 知道的告诉我
从老外论坛上摘的吧?dllimport肯定是调用dll了,关键是调用哪个dll,entrypoint又是什么,只有天知道,也不知道老外是怎么知道的了。
...........
entrypoint 是dll中被调用的函数名称。
07以上的版本不需要这么麻烦的,程序如下: using autodesk.autocad.runtime; using system.runtime.interopservices; using system.windows.forms; namespace progressmetertest { public class cmds { [commandmethod("pb")] public void progressbarmanaged() { progressmeter pm = new progressmeter(); pm.start("testing progress bar"); pm.setlimit(100); // now our lengthy operation for (int i = 0; i <= 100; i++) { system.threading.thread.sleep(5); // increment progress meter... pm.meterprogress(); // this allows autocad to repaint application.doevents(); } pm.stop(); } } }
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
原帖由 月儿 于 dllimport( "acad.exe", charset = charset.auto, callingconvention = callingconvention.cdecl, entrypoint = "?acedsetstatusbarprogressmeterpos@@yahh@z" 这一句 什么意思 ...
这个很复杂的,你的程序是老外的blog上看到的吧,他的blog上有这方面的内容介绍,你以p/invoke关键字查询就能查到有关的文章了。
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
才鸟:您的那段,当i的值比较大时,特别慢,把system.threading.thread.sleep(5);调到循环体的外部比较好。
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多