AnsweredAssumed Answered

Storing selected edges in listbox and parsing through on button command

Question asked by Randy Wong on Apr 15, 2020
Latest reply on Apr 16, 2020 by Evgenij Polupan

Hi All,

I am working on a small add-in for Solidworks in which a side task bar is displayed with a listbox.  The user selects one/more edges of a part and clicks a button that adds the edges to the listbox.  A second button command then fires calculations based on the edges in the listbox.  

 

So I need a way to store the ID of each edge so I can reference them later in the calculations. 

As a test I started with this code to see if I can at least show all the IDs of selected edges.

 

Dim swModel As ModelDoc2 = swApp.IActiveDoc2
Dim sMgr As SelectionMgr = swModel.SelectionManager
Dim sEdge As Edge
Dim sType As swSelectType_e

 

For index = 1 To sMgr.GetSelectedObjectCount2(-1)
   sType = sMgr.GetSelectedObjectType3(index, -1)

   If sType = swSelectType_e.swSelEDGES Then
            sEdge = sMgr.GetSelectedObject(index)
            Debug.Print(sEdge.GetID.ToString())
   End If
Next

 

The result I get is all zeroes / "0" instead of what I would imagine the would be the internal ID that would let me access that edge later on.

 

So I'm sure I'm missing something.  How would I go about storing a reference to each selected edge that I can use to reference later on?

 

I appreciate any help you can give!

 

Randy

Outcomes