Need C# example of how use RecognizeFeatureAutomatic with API

Hi all,

I'm looking for a C# example of how uses the RecognizeFeatureAutomatic method from IFeatureWorksApp Interface. I've found two examples. The first is in VBA (2020 SOLIDWORKS API Help - Recognizing Features Automatically (VBA)). Which I try to convert in C# but with no success. The second is :

ModelDoc2 swModel = SwApp.GetFirstDocument();
int retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetCreateNewPart 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetAllowFailedFeatureCreation 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetBodyCheck 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetAddConstraintsToSketch 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetEnableAutoDimOption 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetDimensionScheme 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetHorizontalPlacement 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetVerticalPlacement 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetPerformBodyDiff 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetExtractFeaturesOnOpenPart 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetAllowWizardHoleRecognition 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetCombineFilletsAutomatic 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetCombineChamfersAutomatic 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetCombineHolesAutomatic 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetFeatureIntrusionCheckOption 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetEFLocalRecognitionPromptOption 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetAutomaticFeatureRecognition 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetInteractiveFeatureRecognition 1");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "RecognizeFeatures");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetAutoDimOptions 1 0 0 0");
retval = SwApp.CallBack("fworks@FWPlaybackManager", 0, "SetAutoRelOptions 1");
swModel.Extension.RunCommand(-2, "");
swModel = null;

Which I found here :

 

This one works for me, but I can't find any documentation on how to set the options of Callback method to choose which function to recognize. To be more precise, this code allows hole recognition, which I don't want.

Here's what I also try :

ModelDoc2 swModel = SwApp.GetFirstDocument();
IFeatureWorksApp swFworkAddin = SwApp.GetAddInObject("FeatureWorks.FeatureWorksApp"); 
BoolStatus = swFworkAddin.SetAdvancedOptions(4);
BoolStatus = swModel.Extension.SelectByID2("Imported1", "BODYFEATURE", 0, 0, 0, false, 0, null, 0);
IntStatus = swFworkAddin.RecognizeFeatureAutomatic(39);
BoolStatus = swFworkAddin.CreateFeatures(3);
swFworkAddin = null;
swModel = null;

With the above code, all seem good (I get the handle of swModel and swFworkAddin) till the SetAdvancedOptions. This method return always false with all the option possibilities (I try them all). After that, only the SelectByID2 method works, RecognizeFeatureAutomatic return 0 (no feature recognize) and obviously CreateFeatures return false. 

Help me please!

Eric

EDIT : Maybe good to mention that I make calls to the API from a standalone Winform application.

SolidworksApi/macros