HI, I need to highlight faces when user do a multi-selection to show which faces are selected and I get a List of faces to save faces selected but when I use Face2 : Highlight to highlight faces, I can't get any face highlighted, actrually it seems Face2:Highlight does nothing in my program.
Can anyone help me?
SolidworksApi macros
Rex,
I am not sure if this helps you but this is my experience. I had a similar functionality and I think highlight did not work (but I do not remember it now). Instead, I found that using Edge::Display() gives better results. It allows you to display the edge in a different color with a different line width. You can get the array of underlying edges from Face (Face2:: getEdges()) and call this for each edge.
Hope it helps!!!
Rajat Jain
Hi, Rajat,
Thank you for your advice, as I may also have to highlight or something to show the selected edge, Edge::Display() will not help in my case.
Actrually, the best way for me is Entity::Select2(true,1) , but the problem is i use it in the eventhandler of select, so if I use this I will get trouble with a second select, that confuses me. Do you know any way I can avoid that?
Rex Ray
I've been fighting this for an hour but can't get a face to be selected.
I have a linear pattern of a single hole wizard hole. I select a linear patter face, get the parent hole wizard, get the only face in that hole wizard feature, then select it. The return value is true, meaning success, but the face isn't selected.
I'm going to bed
Sounds like the code I posted yesterday... I tried it before posting and it seemed to work. Can you post what you're trying?
Haha no your code works perfectly Still, after 10-15 years.
I'll post what I have later. I'm trying to select the single face in a hole wizard feature, that is used to create a linear pattern. I want to highlight the parent's face when someone selects a child face in the linear pattern.
I decided to read the help file on IEntity.Select4 another time:
2016 SOLIDWORKS API Help - Select4 Method (IEntity)
Found this at the bottom:
So I stripped down my add-in to work on parts, and voilá, the face is selected. That means my logic is correct and that I need to find another way to get the face/entity.
Read this for how to convert pointers to assembly space:
Thanks, that was the final piece of the puzzle. Turns out I got the hole wizard feature with GetSelectedObject6, so that was in assembly context. But when I got the seed for a linear pattern, the PatternFeatureArray is apparently in model context.
That means I learned three useful new methods:
2017 SOLIDWORKS API Help - GetCorresponding Method (IComponent2) (convert pointer from model to component)
2016 SOLIDWORKS API Help - GetSelectedObjectsComponent3 Method (ISelectionMgr) (to get the component that owns the selected object)
2016 SOLIDWORKS API Help - FeatureByName Method (IComponent2) (but I didn't need it, now that I can convert pointers)
Hi Rex,
Highlighting is an old API call that just emphasizes the face edges, and only temporarily. It doesn't look like a selection, rather it looks like the model when you hover your mouse over a face. Anything that refreshes the screen will clear the highlight. I don't believe it works with multiple faces either.
I've accomplished something similar using the selection techniques, but maintaining an additional Boolean variable that tells the event handler to ignore selections made by code.
If you use a Property Manager Page for the selections, they'll behave just like standard SOLIDWORKS multi-select, but that UI takes a little more work.
Mike