public void MultipleSelection(string childNodeValue1, string childNodeValue2)
{
try
{
SldWorks swApp = Utility.ConnectToSolidWorks();
ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;
swModel.ClearSelection2(true);
string targetComponentName1 = childNodeValue1.Split(new[] { " - " }, StringSplitOptions.None)[0];
string targetFeature1 = childNodeValue1.Split(new[] { " - " }, StringSplitOptions.None)[1];
string targetComponentName2 = childNodeValue2.Split(new[] { " - " }, StringSplitOptions.None)[0];
string targetFeature2 = childNodeValue2.Split(new[] { " - " }, StringSplitOptions.None)[1];
// Use LINQ to find the Vector3D object with the specified component name and feature
var result1 = pointList.FirstOrDefault(v => v.ComponentName == targetComponentName1 && v.Feature == targetFeature1);
// Use LINQ to find the Vector3D object with the specified component name and feature
var result2 = pointList.FirstOrDefault(v => v.ComponentName == targetComponentName2 && v.Feature == targetFeature2);
bool status1 = swModel.Extension.SelectByID2(result1.Feature + @"@" + result1.ComponentName + @"@" + Path.GetFileNameWithoutExtension(swModel.GetPathName()), "BODYFEATURE", 0, 0, 0, true, 1, null, 0);
bool status2 = swModel.Extension.SelectByID2(result2.Feature + @"@" + result2.ComponentName + @"@" + Path.GetFileNameWithoutExtension(swModel.GetPathName()), "BODYFEATURE", 0, 0, 0, true, 0, null, 0);
swModel.ViewZoomToSelection();
IModelView activeView = (IModelView)swModel.ActiveView;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I selected a hole feature by (“feature name” @ “component name” @ “assembly name”), but now I want to select a single hole in this hole feature. How do I modify my code?