Sometimes you need to run the command more than one to record it into a macro thru recording. Personally, I don't use it because the macro includes extra unused variables
Anyway, there need an array as shown in the sample (from API help) since it needs to go thru each component and check the visibility\
if you don't like the array, you can use a while loop thru all components in the assembly
Those are two different functions. One of which is available in the API, the other appears to not be available.
Show Components, from the flyout toolbar, is available using ShowComponents2 (this one worked for me using the macro recorder).
Show with Dependents does not seem to be available in the API. Show Components only shows the top level components, while Show with Dependents shows everything, including hidden components in sub assemblies. If you have a sub assembly with a hidden component, Show Components will not make that component visible, but Show with Dependents will.
I've done this using GetComponents on the assembly, and then SetVisibility on each component.
Assume swAssembly is an AssemblyDoc object.
Dim Components as Variant
Components = swAssembly.GetComponents(False)
For each swComponent in Components
swComponent.Visible = swConst.swComponentVisibilityState_e.swComponentVisible
You can also refactor this code bearing in mind that setting an component assembly to visible will automatically set all of its children to visible as well.
The docs are a bit messed up 2013 SOLIDWORKS API Help - Visible Property (IComponent2).
In the members of page IComponent2, it says the Visible gets the visibility of the component but does not say anything about setting the visibility, however, a c# setter is mentioned in the property declaration. I've tested this in C# and it works for me.
Something to bear in mind: if you're working with large assemblies, you'll be dissappointed by the execution time of the snippet. This is due to the fact that SOLIDWORKS, by defaul,t uses an animation that last a sec of two to show/hide components. Make sure to set that to 0 from the options and this snippet will be blazingly fast.
Thanks I will look into this,
I like the thought of selecting the top level assembly, & "showing"...seems more direct and just as effective.
I had already caught the issue with the animation and was using (my users like the animation):
Turn Off: SetUserPreferenceDoubleValue(swUserPreferenceDoubleValue_e.swViewTransitionHideShowComponent, 0)
Before closing Turn On: SetUserPreferenceDoubleValue(swUserPreferenceDoubleValue_e.swViewTransitionHideShowComponent, 0.625)
Thanks for all the help again.