Hello I'm trying to retrieve the name of the entity I select in my room (whether it's a face, an edge, or a dot) but I'm stuck, do you have an idea?
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swPart As SldWorks.PartDoc
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swPart = swModel
Dim swEnt As Object
Set swEnt = swSelMgr.GetSelectedObject6(1, -1)
Debug.Print swPart.GetEntityName(swEnt)
End Sub
Hello This code works on my end. But I would rather write it like this:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Dim swEnt As SldWorks.Entity
Set swEnt = swSelMgr.GetSelectedObject6(1, -1)
Debug.Print swModel.GetEntityName(swEnt)
End Sub