Dropping shape to split a connector and auto connect the other shapes

Started by keokoo, March 21, 2018, 09:42:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

keokoo

Hello everyone,
I want to do this programmatically:
Drop a shape (let's call the shape: C) over a connector between two shapes (let's call them: A & B), and the connector auto splits to two connectors, and connects A-C and C-B

Before:             
A
|
B

After:
A
|
C
|
B

I want to do this in the moved event of shape, and inside the event handler, to get the overlapped connector, removes it and creates two new connectors to connect the shapes.

But questions are:
1. are there a moved event of shapes
2. how to detect and get the overlapped connector

Would you please give me some advices?

Thanks,
Keo

Nikolay

I would recommend you don't capture this "hover" event, but listen to connection added/connection removed instead.
Means, you configure a shape to split connectors (it's a shape property - "allow shape to split connectors", a checkbox).
And watch for connections added/removed.

Is it acceptable?

The approach to watch move/overlap is quite error-prone, and I would recommend to avoid that at all costs.
Let Visio do the heavy lifting for you here.

Yacine

It's not clear what you want to achieve.

1) Dropping manually a shape over a connector to split it is already implemented and does not need additional coding
2) If you drop programmatically a shape and want to set it between two shape, you can get the connector by code and replace it by 2 new connectors. No move or drop event involved here.
Yacine

wapperdude

Does this really need to be done programmatically?  Seems in this case, manual operation is more efficient.  To do it via program you somehow need to:
1) identify the connector to be split...manual selection.
2) get its placement...easy enough once identified
3) drop shape on the connector to achieve splitting/reconnection...
      a) always same shape?
      b) always same stencil?
      c) always same stencil location?

Another issue...Is there room for shape to fit?  Visio can move shapes away on-drop, but what does this do to the look of your diagram?  Will you need to go back and manually re-arrange?

Just seems there is enough that needs to be put in the code to make the whole process inefficient, and n the end, still require some manual intervention.

Just saying...

Wapperdude and his two copper disks.   ;D
Visio 2019 Pro