|
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 |
|