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
API Set Component Display States From Folder Selection?
Re: API Set Component Display States From Folder Selection?
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
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