查看单个帖子
旧 2009-04-13, 12:36 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】macro for sheetmetal flat pattern

macro for sheetmetal flat pattern
i am new to macros in sw and was trying to make one that would take a part that is intended to be sheetmetal and make it a sheetmetal part, and add the flat pattern as a derived configuration. this would be done once the part is opened an on my screen. attached is one i recorded for a particular part but it only works on that part. how can i make it a general macro that will work on all parts?
edited: 08/18/2008 at 12:01 pm by kevin harms
recorded macros will always use the selection manager heavily and selectbyid2 which is recorded to select something by its name. since the name of the flat pattern feature could always be different, it doesn't work. however, you can traverse all features in the model and find which one is the flat pattern with the following macro. i've added the unsuppress call as well.
'
sub main()
dim swapp as sldworks.sldworks
set swapp = application.sldworks
dim model as sldworks.modeldoc2
set model = swapp.activedoc
dim features as variant
features = model.featuremanager.getfeatures(true)
dim feat as sldworks.feature
dim i as integer
for i = 0 to ubound(features)
set feat = features(i)
if feat.gettypename2 = "flatpattern" then
feat.select2 false, -1
model.editunsuppress
end if
next
end sub
'-----------------------
mike spens
"automating solidworks using macros"
leap frog leap pad x64
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)