几何尺寸与公差论坛------致力于产品几何量公差标准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-13, 02:46 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】sw configuration check

sw configuration check
hi,
i have a part with 180 configurations.
is there a macro available which will run thru all the configurations and give a list in case there are errors in any of the configurations?
thanks,
rkam
check out our whitepaper library.
there are api calls that do this, but they do not do a complete job of getting all of the information.
another way to check is to create a new design table. a new design table wil automatically detect all config-specific parameters.
you mean something like this?
code
dim swapp as sldworks.sldworks
dim swdoc as sldworks.modeldoc2
dim swconfigmgr as sldworks.configurationmanager
dim swconfig as sldworks.configuration
dim swconfigs as variant
dim swfm as sldworks.featuremanager
dim swfeat as sldworks.feature
dim i as long
dim smsg as string
dim wait as long
dim errcnt as long
dim bhaderr as boolean
sub main()
set swapp = application.sldworks
set swdoc = swapp.activedoc
set swconfigmgr = swdoc.configurationmanager
swconfigs = swdoc.getconfigurationnames
set swfm = swdoc.featuremanager
smsg = "errors found in configurations:"
swdoc.visible = false
on error goto seemeagain
for i = 0 to ubound(swconfigs)
swdoc.showconfiguration2 swconfigs(i)
'debug.print swconfigs(i)
set swfeat = swdoc.firstfeature
bhaderr = false
errcnt = 0
while not swfeat is nothing
if swfeat.geterrorcode <> swfeatureerrornone then
bhaderr = true
errcnt = errcnt + 1
end if
set swfeat = swfeat.getnextfeature
wend
if bhaderr then
smsg = smsg & vbcrlf & swconfigs(i) & " - " & errcnt & " error(s)"
end if
'wait = timer
'while timer < wait + 1
' doevents
'wend
next i
if right(smsg, 1) = ":" then
msgbox "no configurations had errors."
else
msgbox smsg
end if
seemeagain:
swdoc.visible = true
end sub
-handleman, cswp (the new, easy test)
sorry. i misread the op.
anyhoo, beware the api call "configurationmanager::getconfigurationparams" that lists the difference between configs. it misses a lot. as i recall, it does not list config-specific suppression states.
thanks handleman.
your macro was exact and works wonderfully.
is there a macro available which will run thru the configs and we are able to see the model updates as it goes thru the configs.

yes. this is actually a modification of that macro. if you want to do both:
code
dim swapp as sldworks.sldworks
dim swdoc as sldworks.modeldoc2
dim swconfigmgr as sldworks.configurationmanager
dim swconfig as sldworks.configuration
dim swconfigs as variant
dim swfm as sldworks.featuremanager
dim swfeat as sldworks.feature
dim i as long
dim smsg as string
dim errcnt as long
dim bhaderr as boolean
dim delay as double
dim wait as double
sub main()
set swapp = application.sldworks
set swdoc = swapp.activedoc
set swconfigmgr = swdoc.configurationmanager
swconfigs = swdoc.getconfigurationnames
set swfm = swdoc.featuremanager
smsg = "errors found in configurations:"
'swdoc.visible = false
delay = cdbl(inputbox("how long would you like to display each config. in seconds?"))
on error goto seemeagain
for i = 0 to ubound(swconfigs)
swdoc.showconfiguration2 swconfigs(i)
wait = timer
while timer < wait + delay
doevents
wend
'debug.print swconfigs(i)
set swfeat = swdoc.firstfeature
bhaderr = false
errcnt = 0
while not swfeat is nothing
if swfeat.geterrorcode <> swfeatureerrornone then
bhaderr = true
errcnt = errcnt + 1
end if
set swfeat = swfeat.getnextfeature
wend
if bhaderr then
smsg = smsg & vbcrlf & swconfigs(i) & " - " & errcnt & " error(s)"
end if
'wait = timer
'while timer < wait + 1
' doevents
'wend
next i
if right(smsg, 1) = ":" then
msgbox "no configurations had errors."
else
msgbox smsg
end if
seemeagain:
'swdoc.visible = true
end sub
-handleman, cswp (the new, easy test)
sooperb handleman.
this was a very good one, more than what i wanted, with the time setting for each config view. very useful, though i did not think of this when i asked you this.
excellent, thank you very much!!!
howdy,
i totally agree - sooperb handleman!
it's a very useful time saver for those that use (or administer) configurations. i'm sure it would be used by many. you should finish it and post it.
thanks rkam for asking about this.
thanks
tobin sparks
quote (tobin1):
you should finish it and post it.
what sort of finishing do you mean? additional functionality?
-handleman, cswp (the new, easy test)
handleman,
it already functions better than expected . i just meant 1) put your name on it 2) add a description 3) maybe add "option explicit" statement. those were the only things i did in order to add it in my list of useful macros. i named the file checkconfigs.swp.
thanks again
tobin sparks
oh. i don't really "post" stuff anywhere but here, and i usually figure that the thread gives description enough. as far as "option explicit" goes, adding it to code that already has properly defined variables really performs no function.
there's really not much here that hasn't been posted in previous threads. i think the bulk of the config changing code came from some example in the api help.
-handleman, cswp (the new, easy test)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】sheet metal automatic derived configuration yang686526 SolidWorks二次开发 0 2009-04-13 02:17 PM
【转帖】how do i reference a configuration specific property yang686526 SolidWorks二次开发 0 2009-04-13 11:51 AM
【转帖】changing configuration names using document manager yang686526 SolidWorks二次开发 0 2009-04-13 09:40 AM
【转帖】configuration id other than configuration name yang686526 SolidWorks二次开发 0 2009-04-12 08:29 PM


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


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