几何尺寸与公差论坛

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

【转帖】how to get sketch name

[复制链接]
发表于 2009-4-12 18:35:16 | 显示全部楼层 |阅读模式
how to get sketch name
here is simple macro i am working on
dim swapp as object
dim part as object
dim selmgr as object
dim boolstatus as boolean
dim longstatus as long, longwarnings as long
dim feature as object
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
dim vsklines as variant
dim vsklines2 as variant
vsklines = part.sketchmanager.createcornerrectangle(0, 0, 0, 0.05776592972092, 0.04718657489548, 0)
part.sketchmanager.insertsketch true
vsklines2 = part.sketchmanager.createcornerrectangle(0, 0, 0, 0.05, 0.06, 0)
part.sketchmanager.insertsketch true
boolstatus = part.extension.selectbyid2("sketch1", "sketch", 0, 0, 0, false, 0, nothing, 0)
part.featuremanager.featureextrusion2 true, false, false, 0, 0, 0.01111, 0.01, false, false, false, false, 0.01745329251994, 0.01745329251994, false, false, false, false, 1, 1, 1, 0, 0, false
end sub
the problem is if i run this this macro it create sketch1 & sketch2 and extrudes sketch1 but fail to create extruded feature on next time as this time sketch name would be sketch2 & sketch3.
now i want to know how to get name of sketch so that i can put the value returned in part.extension.selectbyid2 function to get my job done
thanks
you would just do something like this:
option explicit
dim swapp as sldworks.sldworks
dim swmodel as modeldoc2
dim sketch as sketch
dim feature as feature
sub main()
set swapp = application.sldworks
set swmodel = swapp.activedoc
swmodel.sketchmanager.insertsketch true
set sketch = swmodel.sketchmanager.activesketch
set feature = sketch
msgbox feature.name
end sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-22 23:05 , Processed in 0.037136 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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