Wait for multiple user selections

Programming and macros
User avatar
mp3-250
Posts: 535
Joined: Tue Sep 28, 2021 4:09 am
Answers: 18
Location: Japan
x 595
x 274

Wait for multiple user selections

Unread post 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?
User avatar
zwei
Posts: 700
Joined: Mon Mar 15, 2021 9:17 pm
Answers: 18
Location: Malaysia
x 185
x 597

Re: Wait for multiple user selections

Unread post 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/
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
User avatar
mp3-250
Posts: 535
Joined: Tue Sep 28, 2021 4:09 am
Answers: 18
Location: Japan
x 595
x 274

Re: Wait for multiple user selections

Unread post 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.
User avatar
JSculley
Posts: 574
Joined: Tue May 04, 2021 7:28 am
Answers: 52
x 7
x 806

Re: Wait for multiple user selections

Unread post 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
User avatar
zwei
Posts: 700
Joined: Mon Mar 15, 2021 9:17 pm
Answers: 18
Location: Malaysia
x 185
x 597

Re: Wait for multiple user selections

Unread post 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)
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
Post Reply