Possibility of using the same Selection string or id to select a component in Modelling environment and Drawing environment using Solidworks API.
Why do you want to use selection string instead of the pointer to the object?
Can you please share a sample for it.
Check this example: Selecting entities in drawing view using SOLIDWORKS API
Hope that works good for Parts.
I have the selection string/id of the component in Assembly in Assembly, need a method to select the same in Drawing based on Drawing View1 for example.
Select component in feature tree using its name via SOLIDWORKS API
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swComponent As SldWorks.Component2
Dim boolstatus As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelectionMgr = swModel.SelectionManager
Set swComponent = swSelectionMgr.GetSelectedObject6(1, -1)
Debug.Print "Name of component to which the selected entity belongs: " & swComponent.GetSelectByIDString
The optimized approach to use swComponent.GetSelectByIDString of Modelling environment in Drawings. I can modify the string based on Drawing View but is there any direct approach for it.
Try this approach: Get the pointer to component from name using SOLIDWORKS API
So you will get the pointer to IComponent2 in the assembly from name which you can then selection in view using the first example.
Retrieving data ...