how to cancel the selection of one of the face after i selcet some faces via api

hi,everybody!

now i want to cancel the selection of one of the face after a i select some faces, i do not know how to do it via api.

as you know ,if i choose a face, the api"select4" will be ok. then how to cancel the selection of a face via api and the other faces is still selected?

any idea is welcome! thank you!

SolidworksApi macros
Answers 4
SF
SF 2010-11-02 Best Answer

There's a DeselectByID method of ModelDoc2 you could use, but you have to know something about the face you want to remove from the selection, so this might be tough.  I've usually taken the approach of having my application monitor each of the user's selections to make sure they are valid and only allow them if they are.  If you can explain your use case, someone might be able to give you more ideas.

SF
SF 2010-11-02

If you do select4 for some face twice, there should be no selections as the first time selection selects and second time select deselects if the documentation can be believed. You can use deselect in some situations also and of course clearselection and redoing the selections that are needed. Just few of the options.

FV
FV 2010-11-02

Hi Wen, you can store the needed info to select these faces in a collection...and add/delete items as you wish to select/deselect...and once you're ready to perform (or even just preview the selections...) your actions on these selected faces, you can iterate through the collection and select all the faces with the info stored in the collection. This way you don't have to deal with unselecting/appending/etc...

cheers

SF
SF 2010-11-03

hi, thank you for your help!

i have solved my problem by API"setfaceID".

i think your idea is also good, i try to use "deselect2", but i do not know how to do it, so any good axample about the use of "deselect2" is very helpful to me. i am waiting for your reply, thank you!