几何尺寸与公差论坛

 找回密码
 注册
查看: 708|回复: 0

【转帖】sw configuration check

[复制链接]
发表于 2009-4-13 14:46:16 | 显示全部楼层 |阅读模式
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)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2025-1-3 10:25 , Processed in 0.036696 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表