Visio Guy

Visio Discussions => Shapes & Templates => Topic started by: CoreBuild on January 06, 2015, 03:34:44 AM

Title: Connecting directly to connection points and not "glue to shape"
Post by: CoreBuild on January 06, 2015, 03:34:44 AM
I have a series of customer master shapes that I have built in a custom stencil that I run in Visio 2010 and Visio 2013.  They are basically two ovals - one is called Start and one is called End. 

Each shape consists of the following:
An oval shape - containing:
- A group - containing:
     - A ConnectorMap shape, which includes a connection point
     - A Data shape, which has all of the data I need

On the Start shape - the connection point on the ConnectorMap shape should only take outbound connections.  On the End shape the connection point on the ConnectorMap should only take inbound connections.  That detail is a bit superfluous but I figured I'd mention it.

Anyway, the problem that I'm having is that I don't want these shapes to be able to be glued to anywhere except for the connection point.  I've been working on this for a while but it still appears to be a mystery to me.

In the case of the Start shape, I can't even connect a connector to the connection point.  I keep getting a "Glue to Shape" behavior even though I can see the connection point dot when I'm moving the connector.  In the End shape, I can get the connector to glue to the connection point or the shape, which I suppose is better.  The problem there is that both the beginning and the end of the connector can be connected to that point.  My connection points on both shapes are of "Type / C"=0.

Does anyone have any ideas as to how I can prevent the shapes from being about to be glued to and/or proper directional connections?

Thanks!

Title: Re: Connecting directly to connection points and not "glue to shape"
Post by: JuneTheSecond on January 06, 2015, 06:07:17 AM
QuoteI don't want these shapes to be able to be glued to anywhere except for the connection point.
You can customize as you wish with programing, VBA or any other.
That is, the program rejects connection, if the connection is not to the specified connection point.
Title: Re: Connecting directly to connection points and not "glue to shape"
Post by: Yacine on January 06, 2015, 12:50:32 PM
Hi CoreBuild,
I would add to Junichi's answer, that the gluing is controlled at application level.
The user can modify the settings at will. There's no integrated solution for controlling this at shape level.


If you want to control the behavior of the gluing, you must catch the gluing event and modify the connection to your needs (... with VBA!).
Something like "connector has been glued to a shape" --> "is it the right shape?", "is it the right point?" ELSE "delete connection", "make new correct connection" or "Message: So and so"


I haven't done this before, but I could imagine that it is feasible with a fair amount of work.


HTH,
Yacine
Title: Re: Connecting directly to connection points and not "glue to shape"
Post by: CoreBuild on January 06, 2015, 07:22:30 PM
That seems doable.  Just to clarify...this is a macro that I would add to the stencil to control shape events or to the document to catch document events?

I looked through the reference but the event to capture isn't obvious to me...

Thanks again for the suggestions.
Title: Re: Connecting directly to connection points and not "glue to shape"
Post by: Yacine on January 06, 2015, 09:16:05 PM
Hi CoreBuild,
I found some links that may help you:
http://msdn.microsoft.com/en-us/library/office/ff768100(v=office.15).aspx
http://flylib.com/books/en/2.268.1.122/1/
https://social.technet.microsoft.com/Forums/office/en-US/75055290-ecd0-4dfd-8df5-4e5212b8283c/how-to-catch-the-visevtconnect-event?forum=visiogeneral

Note that the code is better kept in a stencil - despite it is more difficult, because you will need to set up an event sink. (see above)
Title: Re: Connecting directly to connection points and not "glue to shape"
Post by: JuneTheSecond on January 07, 2015, 12:38:02 AM
And here is a set of my drawing and stencil.
Stencil has VBA macros.
In "calc.vsd" conection will be rejected when you glue to other than connection point.