几何尺寸与公差论坛

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

【转帖】macro for sheetmetal flat pattern

[复制链接]
发表于 2009-4-13 12:36:51 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 13:49 , Processed in 0.034378 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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