I am working on reworking out companies' in-house solidworks toolbar to a newer, easier to maintain version, but i am being stumped by a specific API call.
One process in the toolbar requires me to select the origin of a component X levels deep into subassemblies on a drawing, and since i want to attach a Balloon to it, this needs to happen with "SelectByID2".
now; to create the selection string, i have a small utility method that is used on several locations:
StringBuilder builder = new StringBuilder("Point1@Origin@");
builder.Append("@" + swView.Name);
string fileStructure = comp.Name2.Split('/');
builder.Append("/" + fileStructure);
builder.Append("@" + swView.RootDrawingComponent.Name.Split('-'));
for (int i = 1; i < fileStructure.Count(); i++)
builder.Append("/" + fileStructure[i] + "@");
builder.Append(fileStructure[i - 1].Split('-'));
The problem in this method lies in "Component2::Name2" it only returns the components' own name with the indexer, not the entire hierarchy that the API documentation claims it should return.
I would expect the call to return "Assem4-1/phantom-1/Part1-1", but i only get "Part1-1".
I have confirmed that i indeed am referencing the correct component.
Trying to build my own full name, i called "Component2::GetParent", but the debugger claims that this method does not exist, despite suggesting it during autocomplete.
To make things even more interesting, "Component2::GetSelectByIDString" does realize that the current component is in an assembly, as it returns "Part1-1@phantom", but it fails to realize that "phantom" itself is a subassembly.
Even stranger is the fact that this exact same call in VB.Net (same assembly, same references, same method of reaching the component) i fact does produce the desired and expected result of "Assem4-1/phantom-1/Part1-1"
The solidworks.interop.sldworks dll version in use is 18.104.22.168; i am unable to change this, and the language in use is C#; this also won't change.
Does anyone have any insight over the difference between the languages, or a different method of attaching notes? (i tried component.select, this is not accepted by the API)