4 Replies Latest reply on Mar 8, 2019 10:41 AM by Alex Baer

    IModelDoc2::BlankRefGeom does not work where BlankSketch does.

    Joshua Grant

      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<SfDocument, IEnumerable<IFeature>> getFeaturesMethod)
          var activeModel = SolidWorks.ActiveModel;
          var models = ModelService.GetAllUniqueModels(activeModel);
          int hidden = (int)swVisibilityState_e.swVisibilityStateHide;
          foreach (var model in models)
              var visibleFeatures = (
                      feature in getFeaturesMethod(model)
                      feature.Visible != hidden
              var modelDocument = model.ModelDocument;
              foreach (var feature in visibleFeatures)
                  feature.Select2(true, 0);


      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.