AnsweredAssumed Answered

MacroFeature - Display error message

Question asked by Alexandre Gragnano on Nov 24, 2016
Latest reply on Nov 24, 2016 by Artem Taturevych

Hello,

 

I would like to display an error message after that the user clicks on OK button like this:

 

error.png

 

I tried: 2017 SOLIDWORKS API Help - Regenerate Method (ISwComFeature)

 

dynamic ISwComFeature.Regenerate(object objApp, object objDoc, object objFeat)
{
    var feat = (Feature)objFeat;
    var data = (MacroFeatureData)feat.GetDefinition();
    if (data.GetSelectionCount() == 0)
        return "Selection is empty";
    ...
    return true;
}

 

Result: Does not display any error message contrary to the documentation says :

Return Value

Any one of the following values:

  • True if the rebuild is successful (independent and modify)
  • False if the rebuild failed
  • String, as displayed in an error message to the user (see Remarks)
  • Body, if a body was created

 

I tried: 2017 SOLIDWORKS API Help - OnClose Method (IPropertyManagerPage2Handler9)

 

void IPropertyManagerPage2Handler9.OnClose(int reason)
{
    if (reason == (int)swPropertyManagerPageCloseReasons_e.swPropertyManagerPageClose_Okay)
    {
        var mgr = (SelectionMgr)ModelDoc.SelectionManager;
        if (mgr.GetSelectedObjectCount2(mark) == 0)
            throw new COMException("Selection is empty", 1);
        ...
    }
}

 

Result: Cancel the property page close but does not display any error message.

 

Have you got an idea ?

Thank you

Outcomes