Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro about select loop

Status
Not open for further replies.

omidamir

Mechanical
Joined
Jan 29, 2016
Messages
1
Location
US
hello
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 "loop.select" 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)


Next
Next
Debug.Print swLoop.Select(swEdge, True, swSelData)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top