I am using a macro to zoom to a selected body from a weldment cutlist and would like to isolate the selected body. Is there a VBA command that isolates bodies?
Using SW 2014 Service Pack 2
Try the following code. Works both for selected bodies and components:
Dim swApp As SldWorks.SldWorks Sub main() Set swApp = Application.SldWorks 'isolate swApp.RunCommand swCommands_Comp_Isolate, "" Stop 'exit isolation swApp.RunCommand swCommands_Comp_Isolate_Exit, ""End Sub
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
swApp.RunCommand swCommands_Comp_Isolate, ""
swApp.RunCommand swCommands_Comp_Isolate_Exit, ""
Regards, Artem Taturevych | Snr. Developer | IC3D ANZ
IC3DSteel – New Steel Solution for SolidWorks
translationXpert – SolidWorks files language translator
LinkedIn - SolidWorks API Group
Sorry no function for ISOLATING bodies but you can hide all except selected and then show all.
Thanks for sharing that Artem. When I tried searching for "ISOLATE", the help files didn't showed up anything for bodies/components. So how to find these type of commands.
Well, technically there is no API for isolating as you already stated. I would separate the command APIs like in this case. Usually when I cannot find any direct API method in a search I'm searching through the swCommands_e enumerator for key values and checking each one.
The commands API is pretty rich but we should consider the following drawbacks:
1) It is only applicable for 'void' commands. By 'void' I mean the commands which are not expecting any parameters to be passed. For example if you want to find the command to change the extrusion depth you won't be able to do this because in this case depth is expected to be passed.
2) I'm not sure why but it always a small delay (~1 sec) when using the RunCommand API. It has a big influence to performance when you are repeating it very often.
I'm looking into Command API in 2 general cases:
1) I cannot find the API in regular interfaces
2) I need to invoke some user command (not function). For example show file browse dialog, open property page etc.
Thanks for sharing that Artem
Thank you very much for you help!
Retrieving data ...