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


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


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 10:44 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】userprogressbar help

userprogressbar help
happy new year, api people! i have a macro with a userform. when i click on finish, it takes a good amount of time for the macro to complete its processes. what i would like to do is, when i click on the finish button, use the progress bar in the status bar in solidworks to show the overall progress, as well as update the title during the progress. the example provided in api help is useful, but it doesn't give a clear picture on how to show progress coincident with the macro's progress. other examples use the timer and doevents processes, which i think would complete it, but i don't know exactly how to bring the two concepts together. does anyone have a clear example that would help me perform this operation? your input is greatly appreciated!!
to defeat the wheat, go against the grain.
if you want to use timer, you need to know before, how big "amount of time" would be. because you need to set up upperbound value.
progressbar is only indication of time. choose in your code points where you increase position of pb.
ok, here is the code i have so far:
sub statusbar()
dim x as integer
dim mytimer as double
dim pb as userprogressbar
dim swapp as sldworks.sldworks
dim model as modeldoc2
set swapp = application.sldworks
set model = swapp.activedoc
ptotal = nbi + nib + nrh + nfc
swapp.getuserprogressbar pb
pb.start 0, ptotal, ptitle
for x = 0 to ptotal
pb.updateprogress x
pb.updatetitle ptitle
doevents
loop
pb.end
end sub
ptotal is the total amount of time; each variable added is 250, with a potential total of 1000, depending on what procedures (a total of 4) are ran from user selection. what i want to happen is, for each line of code executed, i want the x in the loop to be incremented by 1 and update the progress of the progress bar. essentially, when the doevents line is executed, it should go back to the other procedure and execute the next line in the other procedure. everytime a line is executed, the loop increments and when all of the procedures have been executed, the progress bar should finish at 100%. or is this the wrong application of doevents? how can i accomplish this incrementation for each line of code executed elsewhere in my project? please advise.
thank you!!
to defeat the wheat, go against the grain.
you can set a max value for the progressbar (for example 100 if you have 100 code lines). then set the value from the pgbar to 0. now raise the value of the pgbar always for one point after each code line. i have to say that this is the way in vb.net but i think its near the same way in visual basic i think.
this is what i have hope it helps.
i check all the parts of the assembly and the progress bar fills according to how many parts are left to check.
'set count according to how many parts in assebmly
frmprogress.progressbar1.max = swass.getcomponentcount(false) - 1
'loop through all parts
for i = 0 to swass.getcomponentcount(false) - 1
'progressbar updates in every loop
frmprogress.progressbar1.value = i
next i
hope its not to confusing.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


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

高级搜索
显示模式

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

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



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


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