几何尺寸与公差论坛

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

【转帖】set the suppression state of a 9sub assembly0 and all its children to

[复制链接]
发表于 2009-4-13 14:13:55 | 显示全部楼层 |阅读模式
set the suppression state of a (sub assembly) and all its children to lightweight
i would like to set the suppression state of a (sub assembly) and all its children to lightweight
the 'set all assembly components lightweight or resolved example' api example shows how to set all assembly components to either lightweight or resolved. this example only set the suppression state from the children. and i need to change the suppression state from the sub assembly too.
option explicit
public enum swcomponentsuppressionstate_e
swcomponentsuppressed = 0 ' fully suppressed - no data is loaded
swcomponentlightweight = 1 ' lightweight - only graphics data is loaded
swcomponentfullyresolved = 2 ' fully resolved - model data is completely loaded
end enum
public enum swsuppressionerror_e
swsuppressionbadcomponent = 0
swsuppressionbadstate = 1
swsuppressionchangeok = 2
swsuppressionchangefailed = 3
end enum
sub processcomponent ( swapp as sldworks.sldworks, swmodel as sldworks.modeldoc2, swcomp as sldworks.component2, swcomponentsuppressionstate as swcomponentsuppressionstate_e, spadstr as string )
dim vchildcomparr as variant
dim vchildcomp as variant
dim swchildcomp as sldworks.component2
dim nretval as long
vchildcomparr = swcomp.getchildren
for each vchildcomp in vchildcomparr
set swchildcomp = vchildcomp
nretval = swchildcomp.setsuppression2(swcomponentsuppressionstate)
debug.print spadstr & swchildcomp.name2 & " <" & swchildcomp.referencedconfiguration & "> --> " & swchildcomp.getpathname
processcomponent swapp, swmodel, swchildcomp, swcomponentsuppressionstate, spadstr + " "
next vchildcomp
end sub
sub main()
dim swapp as sldworks.sldworks
dim swmodel as sldworks.modeldoc2
dim swfeatmgr as sldworks.featuremanager
dim swconfigmgr as sldworks.configurationmanager
dim swconfig as sldworks.configuration
dim swrootcomp as sldworks.component2
dim bret as boolean
dim nsuppressstate as long
dim nresponse as integer
nsuppressstate = swcomponentlightweight
set swapp = application.sldworks
set swmodel = swapp.activedoc
set swfeatmgr = swmodel.featuremanager
set swconfigmgr = swmodel.configurationmanager
set swconfig = swconfigmgr.activeconfiguration
set swrootcomp = swconfig.getrootcomponent
swfeatmgr.enablefeaturetree = false
debug.print "file = " & swmodel.getpathname
processcomponent swapp, swmodel, swrootcomp, nsuppressstate, " "
'my code
nretval = swchildcomp.setsuppression2(swcomponentsuppressionstate)
'----------- > the returned value here is a swsuppressionbadcomponent - component object is no longer valid; for example, if a configuration changed
swfeatmgr.enablefeaturetree = true
end sub
what am i missing?
thanks a lot for your help
james
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-22 23:58 , Processed in 0.037006 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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