![]() |
【转帖】delete sketch
delete sketch
just searched over the aip help and could not find the info. of how to delete a part's sketch? thx, chris solidworks 2007 (office pro.) sp5.0 testing solidworks 2009 (pro) sp0.0 dell precision t3400 2 cpu (8500) 3.16 ghz, 3.25 gb of ram window xp pro sp2 nvidia fx 570 6.14.11.6262 you have to get the sketch feature, then you can delete. check out the "delete selected feature example" in the api help. the catch is that you must have the sketch feature selected before you use modeldocextension.deleteselection2. mike spens mike spens "automating solidworks using macros" leap frog leap pad x64 thx, mike what i want to do here is to delete an unwated sketch, not feature is there a way to delete a sketch (recognized by its name) chris solidworks 2007 (office pro.) sp5.0 testing solidworks 2009 (pro) sp0.0 dell precision t3400 2 cpu (8500) 3.16 ghz, 3.25 gb of ram window xp pro sp2 nvidia fx 570 6.14.11.6262 hi chris, a sketch is essentially a feature (have a look at the swselecttype_e for more info) of the part (document it can be an assembly) that it belongs to. find below a macro that will delete a sketch named "sketch1" from a part cheers, --stav. option explicit dim swapp as sldworks.sldworks dim modeldoc as sldworks.modeldoc2 dim partdoc as sldworks.partdoc dim feat as sldworks.feature dim boolstatus as boolean sub main() set swapp = application.sldworks set modeldoc = swapp.activedoc set partdoc = modeldoc set feat = partdoc.featurebyname("sketch1") boolstatus = feat.select2(false, 0) modeldoc.editdelete end sub in this world i am nobody... and nobody is perfect ;) !!! --------- solidworks office 2008 sp4.0 dell precision pws390 nvidia quadro fx 3450/4000 sdi edited: 06/26/2008 at 04:20 am by stavros antoniou thanks, stavros it works like a charm; and i add some lines for the assembly please see the att. code chris dim swapp as sldworks.sldworks dim modeldoc as sldworks.modeldoc2 dim partdoc as sldworks.partdoc dim assemblydoc as sldworks.assemblydoc dim feat as sldworks.feature dim boolstatus as boolean sub main() on error resume next set swapp = createobject("sldworks.application") set modeldoc = swapp.activedoc set partdoc = modeldoc if modeldoc.gettype = swdocassembly then set assemblydoc = modeldoc set feat = partdoc.featurebyname("cog") if modeldoc.gettype = swdocassembly then set feat = assemblydoc.featurebyname("cog") boolstatus = feat.select2(false, 0) modeldoc.editdelete solidworks 2007 (office pro.) sp5.0 testing solidworks 2009 (pro) sp0.0 dell precision t3400 2 cpu (8500) 3.16 ghz, 3.25 gb of ram window xp pro sp2 nvidia fx 570 6.14.11.6262 edited: 06/26/2008 at 10:54 am by chris ch you are very welcome. --stav. in this world i am nobody... and nobody is perfect ;) !!! --------- solidworks office 2008 sp4.0 dell precision pws390 nvidia quadro fx 3450/4000 sdi quick |
所有的时间均为北京时间。 现在的时间是 11:21 AM. |