I have a macro that is used only in drawings to select all the loops of a selected edge.
A few steps later each of the loops can then be selected by the user selecting one of the entries in a listbox in a userform, representings each loop (the first item in the listbox selects the first loop and the second item selects the second loop)What I would like is to add the original edge so this can also be selected using the item in the listbox. The method used to select the loops (and hopefully also the original edge) is MultiSelect2
A few steps later each of the loops can then be selected by the user selecting one of the entries in a listbox in a userform, representings each loop (the first item in the listbox selects the first loop and the second item selects the second loop)What I would like is to add the original edge so this can also be selected using the item in the listbox. The method used to select the loops (and hopefully also the original edge) is MultiSelect2
vEdgeArr(i) = swLoop.GetEdges
returs an array (vEdgeArr) that make up that loop. Other loops can be added to that same array (vEdgeArr) and later be used to select one of those loops with
swModel.Extension.MultiSelect2 vEdgeArr(lstEdges.ListIndex), False, Nothing
How can I add an edge to that same array (vEdgeArr) so that with the MultiSelect2 method I can select that edge again?
The rest of my code here as to try to clarify:
If selID1 = swSelectType_e.swSelEDGES Then
vCoEdgeArr = swEdge.GetCoEdges
swModel.ClearSelection2 True
ReDim vEdgeArr(LBound(vCoEdgeArr))
ReDim vWeldLength(LBound(vCoEdgeArr))
For i = LBound(vCoEdgeArr) To UBound(vCoEdgeArr)
Set swCoEdge = vCoEdgeArr(i) 'vCoEdge
If swEdge Is swCoEdge.GetEdge Then
'get the loop of the currenr CoEdge
Set swLoop = swCoEdge.GetLoop
ReDim Preserve vWeldLength
'select each loop and calculate the total length of all edges in the loop
SelectLoop swApp, swModel, swLoop, swSelData, vWeldLength(i)
'fill vEdgeArr with each edge of the loop
ReDim Preserve vEdgeArr(i)
vEdgeArr(i) = swLoop.GetEdges 'add the loop to the listbox
UserForm1.lstEdges.AddItem "Loop " & i + 1
UserForm1.lstEdges.List(UserForm1.lstEdges.ListCount - 1, 1) = vWeldLength(i)
swModel.ClearSelection2 True
End If
Next
If Not IsEmpty(vEdgeArr(0)) Then
'add the original edge to the array
ReDim Preserve vEdgeArr(UBound(vEdgeArr) + 1)
vEdgeArr(UBound(vEdgeArr)) = swEdge '<-- THIS DOES NOT WORK
, also tried with swEdge.GetCurve and swEdge.GetCoEdges and swEdge.GetCurveParams3
'add the original edge to the listbox
UserForm1.lstEdges.AddItem "Edge"
UserForm1.lstEdges.List(UserForm1.lstEdges.ListCount - 1, 1) = dblWeldLength
End If
The code when an item is selected in the listbox:
Private Sub lstEdges_Click()
If lstEdges.ListIndex >= 0 Then
'select the selected loop and display the total length of all the edges in that loop
swModel.ClearSelection2 True
If lstEdges.ListIndex <= UBound(vEdgeArr) Then
'THIS CODE DOES SELECT THE LOOPS BUT NOT THE ORIGINAL EDGE, WHAT AM I DOEING WRONG?
swModel.Extension.MultiSelect2 vEdgeArr(lstEdges.ListIndex), False, Nothing
End If
End If
End Sub
Can somebody pleas help me with this?
Frank
SolidworksApi/macros