1 ImportsSolidWorks.Interop.sldworks2 ImportsSolidWorks.Interop.swconst3 ImportsSystem.Runtime.InteropServices4 ImportsSystem5 6 Partial ClassSolidworksmacro7 8 Public SubMain ()9 Ten DimSwselmgr asSelectionmgr One DimSwdoc asMODELDOC2 = Nothing A DimSwpart asPartdoc = Nothing - DimBoolstatus as Boolean=False - DimLongstatus as Integer=0 the DimSwsketch asSketch - DimSwfeat asFeature - DimVsketchseg as Object - DimSwsketchseg assketchsegment + DimK as Integer=0 - +Swdoc =CType(Swapp.activedoc, MODELDOC2) ABoolstatus = SwDoc.Extension.SelectByID2 ("Air_low_sketch","SKETCH",0,0,0,False,0, Nothing,0) atSwdoc =Swapp.activedoc -Swselmgr =Swdoc.selectionmanager -Swfeat = SWSELMGR.GETSELECTEDOBJECT6 (1,0) -Swsketch =Swfeat.getspecificfeature2 -Swdoc.clearselection2 (True) -Vsketchseg =swsketch.getsketchsegments in If not IsNothing(VSKETCHSEG) Then - forK =0 to UBound(VSKETCHSEG) toSwsketchseg =vsketchseg (k) +Swsketchseg.selectbymark (True,0) - Nextk the End If * End Sub $ Panax Notoginseng " " <summary> - " "The sldworks swapp variable is pre-assigned for you. the " " </summary> + PublicSwapp asSldworks A the + End Class
SolidWorks Two Development Learning (2) How to select a sketch and traverse all the lines in the sketch (non-sketch edit state)