几何尺寸与公差论坛

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

【转帖】count bends - macro

[复制链接]
发表于 2009-4-13 09:59:03 | 显示全部楼层 |阅读模式
count bends - macro
is there a way that i can capture the number of bends in a sheetmetal part and save them to a configuration specific property?
thanks for any assistance you can provide.
try this. the main code comes from a sample in the api help. change the name of the property in the last line as desired.
'traverse subfeatures example
'this example shows how to traverse the sub-features
'of each feature in a part .
dim swapp as sldworks.sldworks
dim part as sldworks.modeldoc2
sub main()
set swapp = createobject("sldworks.application")
set part = swapp.activedoc
' get the 1st feature in part
dim feature as sldworks.feature
set feature = part.firstfeature
dim featurecount as integer
featurecount = 0
' while we have a valid feature
while not feature is nothing
' get the name of the feature
dim featurename as string
dim featuretype as string
dim subfeat as sldworks.feature
set feature = feature.getnextfeature
featuretype = feature.gettypename2
if featuretype = "flatpattern" then
set subfeat = feature.getfirstsubfeature
' while we have a valid sub-feature
while not subfeat is nothing
' get the type of the sub-feature
if subfeat.gettypename2 = "uibend" then
featurecount = featurecount + 1
end if
set subfeat = subfeat.getnextsubfeature
' continue until the last sub-feature is done
wend
' get the next feature
set feature = feature.getnextfeature()
' continue until the last feature is done
end if
wend
msgbox featurecount & " bends in this part"
'add a custom property
part.addcustominfo3 "", "number of bends", swcustominfotext, cstr(featurecount)
end sub
mike spens
"automating solidworks using macros"
leap frog leap pad x64
thanks mike! i am not sure how i didn't see that in the api samples, but it is exactly what i needed.
denten
denten,
could you pleas upload the macro file.
mohamed abdel moniem | mechanical engineer
cswp, cswa, cswp core, cswp-smtl
solidworks 2009 sp3.0
vista x64 sp1.0
intel q6600, 8gb ram
ati hd 4850
3dconnexions spacenavigator
hi mohamed,
i just used the code that mike posted above. all i had to change was change "featuretype = feature.gettypename2" to "featuretype = feature.gettypename"
and then it works 100% for me.
denten,
actually i've never worked with api or created a macro file, i only use them
so if you don't mind. pleas upload the macro file
mohamed abdel moniem | mechanical engineer
cswp, cswa, cswp core, cswp-smtl
solidworks 2009 sp3.0
vista x64 sp1.0
intel q6600, 8gb ram
ati hd 4850
3dconnexions spacenavigator
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-24 09:53 , Processed in 0.113961 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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