Hide a part feature via API

Dear SolidWorks Experts,

How can I hide a feature inside a part (.SLDPRT) file, via API?

 

I do not mean hide its icon in Design Tree. Which is what this swFeat.SetUIState example does.


I mean do the same functionality as below shown "Hide" in UI:

 

I tried using the swFeat.Visible property, but sadly it only has get, not set method.
 

I would be grateful for any kind of help. Thank you in advance.

Answers 3
TS
TS 2025-11-12 Best Answer

Hi, @DB san.

You might try using IFeatureManager.HideBodies after selecting the feature.

 

DB
DB 2025-11-12

Hello @TS 
That worked! Thank you very much for the help!

SD
SD 2025-11-12

It is beyond me to wrap my head around all the requests to create a macro to do one thing.  Just right-click and hide the feature but so many people request macros to perform one function when that function can be done easily with one or two clicks, certainly less than running a macro.  Very soon AI will be doing everything and we will all be out of a job.  Learn the software people.  Rant over.