Solidworks - VBA - Manipulating Selection Sets in a MEP

Hello everyone,

I need to manage the import of DXF files into our plan management system. However, it often happens that objects are outside the scope of the MEP (these objects are not useful for us). I'm trying to create a macro that would erase all the entities that are out of frame. I manage to select all the entities of the MEP (1st selection set) as well as all the entities within the framework of the MEP (2nd selection set). But I can't select all the entities EXCEPT the ones in the frame: basically do Game1 - Game2.

Someone would know the method to achieve this. Thank you in advance.

I don't see a method to do it in solidworks in 2 steps so same thing in vba in my opinion.

On the other hand, you could do in 4 steps select the entire top banner, delete.

The whole bottom banner deletes and the same for the right and left part.

Which in the end comes down to keeping your central part.

In Solidworks it's "quite" simple:

1.     CTR + A

2.     CTR + Selection Window

3.     Delete

However, using the macro recorder, step 2 goes wrong...

But I'll dig deeper to implement your solution.

1 Like

Indeed, so I withdraw what I said, it must be achievable.

On the other hand, my solution remains viable and just as fast in macro.

 

Otherwise you can also select the window you want to keep and then reverse the selection. (Invert selection)

http://help.solidworks.com/2020/english/SolidWorks/sldworks/t_Invert_Selection.htm?verRedirect=1

To reverse see this page (without having tried):

https://www.eng-tips.com/viewthread.cfm?qid=153986

Or again:

swCommands_InvertSelection564; Selection Filter toolbar > Invert Selection

Link:

http://help.solidworks.com/2020/english/api/swcommands/solidworks.interop.swcommands~solidworks.interop.swcommands.swcommands_e.html

1 Like