Hi everyone!
I'm trying to get component name for method SelectByID2 from assembly. I have simple assembly with one mate, and I want select those components which were selected in this mate.
Here is my code:
var aseembly = iSwApp.ActiveDoc as ModelDoc2;
Feature swFeat = aseembly.FirstFeature();
Feature mates = null;
while (swFeat != null)
{
if (swFeat.GetTypeName2() == "MateGroup")
{
mates = swFeat;
break;
}
swFeat = swFeat.GetNextFeature();
}
Feature swMateFeature = mates.GetFirstSubFeature();
var swMate = swMateFeature.GetSpecificFeature2() as Mate2;
for (int i = 0; i < swMate.GetMateEntityCount(); i++)
{
var entity = swMate.MateEntity(i);
var comp = entity.ReferenceComponent as Component2;
var param = entity.EntityParams as double[];
var selected = aseembly.Extension.SelectByID2("Boss-Extrude1@"+comp.GetSelectByIDString(), "", param[0], param[1], param[2], true, 1, null, (int)swSelectOption_e.swSelectOptionDefault);
}
This code selects wrong points (it should be point and edge). SelectByID2 always returns false, which means that name parameter is incorrect. Anybody know how I can get full name of component programmatically?
SolidworksApi macros