API Set Component Display States From Folder Selection?

Library for macros
eracer55
Posts: 1
Joined: Fri Apr 16, 2021 10:33 am
Answers: 0

API Set Component Display States From Folder Selection?

Unread post by eracer55 »

I'm trying to automate setting the visibility (Hide) of components in various display states. The components are grouped in Folders. I'm able to set each component one at a time using the following:
SetVisibilityInAsmDisplayStates Method (IComponent2)
http://help.solidworks.com/2021/english ... tates.html

This method takes a long time as each component is set one at a time. If I were to do this manually, I would select the folder, and select Hide and all the components in the folder are hidden immediately altogether.

How can I do this through the API in VBA? I can't seem to find a method.

SW2021SP2
User avatar
JPARKER
Posts: 11
Joined: Mon Mar 15, 2021 4:16 pm
Answers: 0
x 8

Re: API Set Component Display States From Folder Selection?

Unread post by JPARKER »

That is because the folder is considered a component not a special container. So something like this will work.

boolstatus = Part.Extension.SelectByID2("FOLDERNAME", "FTRFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Part.HideComponent2
boolstatus = Part.Extension.SelectByID2("FOLDERNAME", "FTRFOLDER", 0, 0, 0, False, 0, Nothing, 0)
Part.ShowComponent2
Post Reply