Page 1 of 1

Wait for multiple user selections

Posted: Wed May 10, 2023 12:40 am
by mp3-250
Hello, I am working on a macro sub used to edit a 3d sketch in a assembly context, we need to copy a portion of a 3D sketch in the assembly (all lines) inside a 3d sketch of the part.

I was able to chain select and copy the entities from the assembly sketch with one click thanks to the api, but I have some cases in which a single chain cannot be selected in full.
This happens with some portion of the assembly 3d sketch in which the lines that are not drawn along X, Y or Z directions but oblique (construction lines srawn along x, y or z and resulting line inclined accordingly). This make the chain to split in two portions. In those cases my one click selection fail to select the whole chain and I should be able to make an additional selection.

Is it possible (in theory) to wait for multiple user selections inside a sketch before continuing the macro execution?

- Sketch already in edit mode inside the main macro
1 Select the first chain clicking one line
2 Select the second chain another line
3 Select the n chain...
4 send all the selections to the macro to be processed (entity copy and fillet between)

Any idea?

Re: Wait for multiple user selections

Posted: Wed May 10, 2023 6:10 am
by zwei
How about...

1. Load up a user form using VbModeless
2. User make whatever selection they need
3. User click on the "button" on the user form to confirm their selection
4. continue the macro

See Artem's Suspend Rebuild macro as an example of using Vbmodeless
https://www.codestack.net/solidworks-ap ... d-rebuild/

Re: Wait for multiple user selections

Posted: Wed May 10, 2023 8:49 am
by mp3-250
As a preamble this is the first "serious" macro project I am developing in SW and I am not a software engineer to begin with.
I am already lauching the main macro from a vbmodeless form (lot of buttons to launch the very same operations with just a different templates) and the sketch edit part is a sub. Launching another form to "pause" the selection like in the link could be a very nice touch. I will give it at try after studying codestack example.

Thank you.

Re: Wait for multiple user selections

Posted: Wed May 10, 2023 11:28 am
by JSculley
mp3-250 wrote: Wed May 10, 2023 12:40 am Hello, I am working on a macro sub used to edit a 3d sketch in a assembly context, we need to copy a portion of a 3D sketch in the assembly (all lines) inside a 3d sketch of the part.

I was able to chain select and copy the entities from the assembly sketch with one click thanks to the api, but I have some cases in which a single chain cannot be selected in full.
This happens with some portion of the assembly 3d sketch in which the lines that are not drawn along X, Y or Z directions but oblique (construction lines srawn along x, y or z and resulting line inclined accordingly). This make the chain to split in two portions. In those cases my one click selection fail to select the whole chain and I should be able to make an additional selection.

Is it possible (in theory) to wait for multiple user selections inside a sketch before continuing the macro execution?

- Sketch already in edit mode inside the main macro
1 Select the first chain clicking one line
2 Select the second chain another line
3 Select the n chain...
4 send all the selections to the macro to be processed (entity copy and fillet between)

Any idea?
It sounds like you should be using a PropertyManagerPage

Re: Wait for multiple user selections

Posted: Sun May 14, 2023 8:49 am
by zwei
JSculley wrote: Wed May 10, 2023 11:28 am It sounds like you should be using a PropertyManagerPage
Never thought you could do something like that with VBA... will definitely give it a try when i have time 8-)

(It does look more complicated than i like)