IModelDoc2::BlankRefGeom does not work where BlankSketch does.

I have 2 macros, one which uses BlankSketch and another which uses BlankRefGeom. The BlankSketch macro hides all sketches in an assembly successfully, but the BlankRefGeom macro only hides features for the top level assembly.

They both follow the exact same process, the only place where they differ is how features are selected.

With the BlankSketch macro, I am selecting all features which conform to the interface ISketch. With the BlankRefGeom macro, I am selecting all features with the type name "RefPlane". For both macros, I am selecting the features via the assembly or part document directly above the feature, i.e. not the top level assembly.

Here's the method, so you can see how I'm doing this. I am making calls to some other code I have written, so it's not entirely complete.

private void HideFeatures(Func> getFeaturesMethod)

{

    var activeModel = SolidWorks.ActiveModel;

    var models = ModelService.GetAllUniqueModels(activeModel);

    int hidden = (int)swVisibilityState_e.swVisibilityStateHide;

    foreach (var model in models)

    {

        var visibleFeatures = (

            from

                feature in getFeaturesMethod(model)

            where

                feature.Visible != hidden

            select

                feature

        );

        var modelDocument = model.ModelDocument;

        modelDocument.ClearSelection2(true);

        foreach (var feature in visibleFeatures)

            feature.Select2(true, 0);

        modelDocument.BlankSketch();

        modelDocument.BlankRefGeom();

        modelDocument.ClearSelection2(true);

    }

    activeModel.ModelDocument.ForceRebuild3(true);

}

When stepping through the code, I can see that the planes are being selected successfully, so I am at a loss to explain why these two macros are behaving differently.

I have had success when selecting items via SelectByID2, but this does not suit my purposes of looping through and finding the appropriate planes to hide.

SolidworksApi macros