I am using SolidWorks 2010 and I ran into problems with marking and setting the color of the elements in a selection set.
My application is written in C# and the API I am using isISelectionManger.set_SelectionColor. In the documentation this method is described as follows (under SolidWorks.Interop.sldworks Namespace > ISelectionMgr Interface : SelectionColor Property):
int SelectionColor(
int Mark
) {get; set;}
My test code does the following:
1) Put 4 Sketch Segments into the selection set. I obtain valid ISketchSegment handles from somewhere (not important here) and I call ISketchSegment.Select2(true, 5) on the first 2 segments andISketchSegment.Select2(true,-1) on the rest.
2) I verified that the selected objects are marked correctly by calling ISelectionMgr.GetSelectedObjectMark and it shows that the selected objects are marked correctly.
3) I want to change the selection color of those segments marked with 5 to be different from the unmarked ones. So I useISelectionMgr.set_SelectionColor(5, (int)swUserPreferenceIntegerValue_e.swSystemColorsDynamicHighlight);
Problem 1
The marked segments are highlight with the same color as the unmarked one (with the default selection color).
Problem 2
ISelectionMgr.GetSelectedObjectCount2(5) returns 4 -- this is incorrect, it should be 2 because it should returns the number of segments which have been marked with 5.
ISelectionMgr.GetSelectedObjectCount2(-1) returns 4 -- this is correct, it should returns the number of all objects in the selection regardless of their marks.
ISelectionMgr.GetSelectedObjectCount2(0) returns 0 -- this is incorrect, it should returns the number of 2 segments which has not been marked.
Notes:
- I have tried using other colors for the "set_SelectionColor" call (e.g. (int)swUserPreferenceIntegerValue_e.swSystemColorsSelectedItem2) and got the same result.
- I have tried calling ISelectionMgr.set_SelectionColor(-1, (int)swUserPreferenceIntegerValue_e.swSystemColorsDynamicHighlight). This should change the selection color of all the objects (regardless of their marks) and I got the same result (their colors have not been changed).
Futhermore:
I would also like to set a thicker line-width on the marked segments (like what one sees when clicking a contour in the selection list of the Extrusion Feature creation dialog). I cannot find any API that will do that.
Has anyone run into the similar problems? Any suggestions?
Thanks.
SolidworksApi macros