Hello
I have a macro that from an assembly, opens the selected part and then applies a certain processing to it.
This macro works very well if in the assembly I select a face of the part to be processed.
On the other hand, I would like to add the possibility to apply this processing by selecting the part from the Feature manager as well (without removing the current possibility from a face in the 3D)
Does anyone have a concrete example or idea of the function to use?
Below is the current code (cleaned):
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swCompEnt As SldWorks.Entity
Dim swPartFeat As SldWorks.Feature
Dim swCompModel As SldWorks.ModelDoc2
Dim swPartEnt As SldWorks.Entity
Dim swConfigMgr As SldWorks.ConfigurationManager
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim nRetval As Long
Set swSelMgr = swModel.SelectionManager
Dim CurSelCount As Long
CurSelCount = swSelMgr.GetSelectedObjectCount
Set swCompEnt = swSelMgr.GetSelectedObject6(1, 0)
Set swComp = swSelMgr.GetSelectedObjectsComponent3(1, 0)
Set swCompModel = swComp.GetModelDoc
Set swConfigMgr = swCompModel.ConfigurationManager
Set swCompModelConfig = swConfigMgr.ActiveConfiguration
Set swModelDocExt = swCompModel.Extension
Set swPartEnt = swModelDocExt.GetCorrespondingEntity(swCompEnt)
Set swCompModel = swApp.ActivateDoc2(swCompModel.GetPathName, True, nRetval): Debug.Assert 0 = nRetval
Dim swConfig As SldWorks.Configuration
Set swModel = swApp.ActiveDoc
swModel.ShowConfiguration2 (swComp.ReferencedConfiguration)
Debug.Print "File = " + swModel.GetPathName
Debug.Print " Component = " + swComp.Name2 + " <" + swComp.ReferencedConfiguration + ">" + " [" + swComp.GetPathName + "]"
Debug.Print " Model = " + swCompModel.GetPathName + " <" + swCompModelConfig.Name + ">"
End Sub