AnsweredAssumed Answered

select outer loop in sketch

Question asked by Omid Amir on Oct 13, 2016
Latest reply on Oct 13, 2016 by Omid Amir


i have a question

i want to write a macro about selecting outer loop in a sketch

how i can select a loop in a sketch???

when i use "" my solidworks error and exits the program


this is my code :


Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swSeg As SldWorks.SketchSegment

Dim swSketch As SldWorks.Sketch

Dim swSketchMgr As SldWorks.SketchManager

Dim swLoop As SldWorks.Loop2

Dim swReg As SldWorks.SketchRegion

Dim vLoop As Variant

Dim vReg As Variant

Dim swEdge As SldWorks.Edge

Dim vEdge As Variant

Dim vEdgeArr As Variant

Dim swFeat As SldWorks.Feature

Dim myPart As SldWorks.PartDoc

Dim swSelData As SldWorks.SelectData

Dim swEnt As SldWorks.Entity

Dim swSelMgr As SldWorks.SelectionMgr


Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set myPart = swModel

Set swSelMgr = swModel.SelectionManager

Set swFeat = myPart.FeatureByName("Sketch1")

Set swSketch = swFeat.GetSpecificFeature2()


vReg = swSketch.GetSketchRegions

For i = LBound(vReg) To UBound(vReg)

Set swReg = vReg(i)

Set swLoop = swReg.GetFirstLoop


vEdgeArr = swLoop.GetEdges


For j = LBound(vEdgeArr) To UBound(vEdgeArr)

Set swEdge = vEdgeArr(i)

Set swEnt = swEdge




Debug.Print swLoop.Select(swEdge, True, swSelData)

End Sub