Get Selected Assembly Part
Posted: Thu Aug 24, 2023 5:58 pm
Hello fellow users, hopefully this is an easy one for you: I'd like to get the selected part in my assembly via macro. I'm close (i think) to the kitchen, I can smell the food, but I can't find the door. I think I need to use GetSelectedMember(), but I can't close the deal. Would one of you be good enough to look at my code and lmk where or what I need to change? Thanks in advance! David
Code: Select all
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swComp As SldWorks.Component2
Dim swAssem As SldWorks.AssemblyDoc
Dim featMgr As SldWorks.FeatureManager
Dim selMgr As SldWorks.SelectionMgr
Dim selComp As SldWorks.Component2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager
Set featMgr = swModel.FeatureManager
Set swAssem = swModel
Set selComp = swAssem.GetSelectedMember
Dim d As String
Set d = selComp.Name
swApp.SendMsgToUser d
End Sub