I would like to determine whether a midpoint of a model edge is selected or not (in drawing environment) before the macro is run. Once successfully determined that, I would like to retrieve the iEdge entity that this midoint belongs to. My ultimate goal is to attach a leadered annotation to this midpoint. I can achieve this for other types of selected entities, such as an edge, vertex, face etc. But midpoint of an edge behaves differently.
When an edge/vertex/face is selected, and an iNote is inserted, the note leader comes attached to the edge/vertex/face. I can then retrieve the properties of the edge/vertex/face. However, when I insert and iNote while a midpoint is selected, the note is not attached to any entity and comes without any leaders. And it is actually located off the page, because solidworks places the note on the drawing coordinate system by using the midpoint's location values from the model coordinate system. This part is not an issue, I can relocate the note, and add a leader to it. However I need to know the edge entity the midpoint belongs to.
You can try this and see. Select a edge/vertex/face of a model in a drawing and run. Then select a midpoint of an edge and run.
Sub Main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swNote As SldWorks.Note Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swNote = swModel.InsertNote("NoteText") End Sub
If I can somehow retrieve the edge entity that the midpoint belongs to, I can figure out the rest.
Thanks in advance.