API: Deselecting from FM tree

Discussion in 'SolidWorks' started by CS, Nov 24, 2004.

  1. CS

    CS Guest

    Has anyone else dealt with this. I created a few programs that have
    residual selections (meaning you select an item it is added to a list and
    then you can select another with out holding CTRL, then you deselect by
    clicking on any selected item, and it is removed from the list.) The
    problem is that when deselecting a feature from the Tree it seems to raise
    the Assm_SelectionChangeNotify event 2 times. This is causing my app to
    loop and deselect everything. When deselecting from the graphics view
    everything works as expected. I have been racking my brain trying to think
    of some other way of deciding which item was deselected. I have been
    using....

    Set ThisComp =
    SelMan.GetSelectedObjectsComponent2(SelMan.GetSelectedObjectCount)

    to get the last object selected. Then I check if it is in my list and if
    the item is found it removes the item if not it adds the item.

    Anyone have any Ideas they would like to share.

    Corey
     
    CS, Nov 24, 2004
    #1
  2. Corey,

    I have not run into this problem, but you could solve it using an old
    programmer's trick.

    Set up a global boolean variable called FirstTime and set it equal to true.
    Then, after the first time, set it equal to what ever it is not. Then, only
    run your code if FirstTime is true. Just make sure you set FirstTime back
    to true after your desired code runs?

    Does that make sense?

    Evan
     
    Evan T. Basalik, Nov 29, 2004
    #2
  3. CS

    CS Guest

    I know what you are saying and I already have that in there but my problem
    is when it is deselecting from the FM tree SW calls the selectionchange
    event lets it run all the way through so my FirstTime switch is set to false
    and back to true, then SW calls selection change again. I can't figure out
    anyway to stop it. I e-mailed API support but they haven't responded yet.

    Corey

    "Evan T. Basalik" <Evan(do not dare spam me -
    remove)> wrote in message
     
    CS, Nov 29, 2004
    #3
  4. CS

    TinMan Guest

    Just a thought, add another conditional statement in there to only
    allow the FirstTime switch to be set to True *if* something was
    *added* to the selection list. If a component was deselected then skip
    the FirstTime switch. May even require a second "global boolean
    variable".

    Ken
     
    TinMan, Dec 1, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.