几何尺寸与公差论坛------致力于产品几何量公差标准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:13 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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



所有的时间均为北京时间。 现在的时间是 05:00 AM.


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