![]() |
【转帖】set the suppression state of a 9sub assembly0 and all its children to lightweigh
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 |
所有的时间均为北京时间。 现在的时间是 05:41 PM. |