Reselect after ForceRebuild3

Discussion in 'SolidWorks' started by Stefan Olofsson, Oct 7, 2008.

  1. Hi all

    I have written this function within a SWAddin. I need to rebuild the
    currently selected/active model and then continue with other actions.
    However, the ForceRebuild3 function deselects the model from the
    selectionmanager and the other actions can not find it again.

    How do I reselect the model after the ForceRebuild3.

    bool CadvSWAddin::RebuildModel(CString theCommand)
    {
    HRESULT hr;
    CString rebuildQuestion = _T("Do you want to rebuild the model before ");
    rebuildQuestion += theCommand;
    rebuildQuestion += _T("?");
    int doRebuild = DisplayUserMessage(G_MessageTypeQuestion, rebuildQuestion,
    _T(""));
    if (doRebuild == Confirm_Yes)
    {
    IModelDoc2* pModelDoc = NULL;
    VARIANT_BOOL result;

    hr = iSwApp->get_IActiveDoc2(&pModelDoc);
    if (hr != S_OK || pModelDoc == NULL)
    {
    return false;
    }

    hr = pModelDoc->ForceRebuild3(VARIANT_FALSE, &result);
    if (hr != S_OK || result == VARIANT_FALSE)
    {
    return false;
    }

    // Here I want to reselect the Model so it appears in the selection
    manager
    pModelDoc->????
    }

    return true;
    }

    Thanks
    Stefan Olofsson
     
    Stefan Olofsson, Oct 7, 2008
    #1
  2. Stefan Olofsson

    That70sTick Guest

    The only thing I can think of is to collect objects that are in the
    SelectionMgr before rebuild and then select them after the rebuild.
     
    That70sTick, Oct 8, 2008
    #2
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.