Angled connectors again

Started by Nikolay, November 15, 2010, 02:51:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nikolay

Hi guys!
I'm trying to create "angled" connector in Visio (with 2 short "stubs" on each side, and a straight line between them), see the screenshot.

I need my connector to glue properly to shape "geometry", and as "walking glue", i.e. to each side of the shape with proper orientation.
I've read these topics:
http://visguy.com/vgforum/index.php?topic=1031.0
http://visguy.com/vgforum/index.php?topic=1637.0

Unfortunately I was unable to find the solutions which would work with "all directions".
Auto-routing which enables proper connection point orientation stops working as long as you change "ObjectType=2" to anything else (which was assumed, as far as I understand, by all solutions in those topics), so Visio just stops routing connectors at all, and I don't want that.

I tried the following approach:
1. Created a second geometry section for connector (i.e. "Geometry2")
2. Hid the first geometry section to allow Visio auto-route (i.e. set NOSHOW=TRUE). Means, I let Visio auto-route invisible connectors in fact.
3. Added the following formulas to the Geometry2 section:


MoveTo: 0, 0
LineTo: COS(ANGLEALONGPATH(Geometry1.Path,0))*User.Indent, COS(ANGLEALONGPATH(Geometry1.Path,0))*User.Indent
LineTo: Width-COS(ANGLEALONGPATH(Geometry1.Path,1))*User.Indent, Height-SIN(ANGLEALONGPATH(Geometry1.Path,1))*User.Indent
LineTo: Width, Height


(the SIN and COS are to create my "stubs" that are properly directed,
and the angle is taken from the auto-routed connector from the first geometry section)

This created exactly the 3-segment-length path I wanted!
And auto-routing still worked.

The point is, the above seems to work only in Visio 2010 (due to "ANGLEALONGPATH", btw - it turns out this might be an useful function :)).
In fact, it would be good enough just to find the find angle of the last segment of geometry1. The point is, I don't know how to do that without these new functions...
I mean, getting the first point in geometry section is pretty easy: Geometry1.X1, Geometry1.Y1; but I don't know how to get the last segment in Geometry1 section (because the number of segments is actually unknown at design time), because connector is routed, and Visio may add/remove segments by itself. Keep in mind, all this happens in shapesheet, so no code is possible.

So the question is does anybody have any ideas about this or how to achieve similar thing in previous version of Visio, or by different means?
The sample drawing attached. Thanks in advance!

vojo

have fun

Rt click and double click

Nikolay

Hi vojo,

Thank you for response!
but it seems that in you example connectors do not auto-route at all? You have ObjectType=4, "Do not route". Am I missing something here? Maybe I mislead you by naming topic a bit wrongly.
I mean, isn't that drawing you posted just the same thing I saw in those 2 topics? Please make sure you've actually read my post ;)

I mean, I need a connector that auto-routes and glues to ANY SIDE of a shape (bottom, top, left, right). And glues with correct angle ;)
See the picture below. In my example connectors are updated, when I just move the green shape around the yellow one.

I need the same thing, but for Visio 2003/2007

vojo

They dont auto route at all.....I just put them here for you get an idea of angles in early versions of visio  (this is based on June's great shapes)
I tend do this kind of thing manually....what I do like is that these connectors can be chained and stay attached to shapes.....so if I move a shape, all the calcuations are done automatically.

Feel free to experitment with object type....maybe it will autoroute if set to 2...I have never tried that....my experience says visio not real good and sort of iso like behaviors.

Jumpy

Hi Nikolay,

Graham Wideman has an example of a custom made connector in his book Visio 2003 Developers Survival Kid, that has special Line Ends that look like "suction cups" (I hobe that is the right word). If I remeber correctly it was neccessary to find out the orientaion in which the last segment of the connector hit the other shape, too, in order to align the suction cups correctly. Maybe that may help you.

I don't have the book anylonger, but maybe someone else here can check that passage.

Jumpy

P.S.: One question. Has the connector always only 3 segments or is this only in the examples?

Nikolay

#5
Hi Jumpy!

Thank you so much!
I had this book on my bookshelf in fact - the thing you were talking about was indeed called "Suction Cup", and worked perfectly! Page 192. BTW, this book is also available in Google Books. So basically what I needed was finding the angle of the first segment of dynamic connector, and the angle of the last segment of the dynamic connector.

The idea (in the book) was that to figure out the angles at the begin and at the end, you can just add 2 extra ("invisible") connection points along the connector path, and calculate the angle using these points, and this works perfectly in 2003 and 2007.

There is a small problem though  ???
The approach from the book does not work anymore in Visio 2010!
The connection points on path do not move along with the path anymore in Visio 2010?! For crying out loud! :)

So now the question is if there is a way to make them work the same way the did before, or if there a way to figure (from a shapesheet formula) that we are running on Visio 2010 and take a different approach instead?

Anyways, yes, I need my connector to have exactly 3 line segments, and auto-glue to shapes (orthogonal to shapes's border). Also I want the connector to auto-route. Kind of straight-line connector, but with two additional "free" segments at the ends, which glue always orthogonal to shape's border, i.e. it should look as these segments they "stick out" of the shape they are glued to. These 2 "hanging" segments are supposed to have fixed length.

Nikolay

#6
Ups. It seems I was wrong about Visio 2010 - the approach works there as well, you just need to specify the coordinates for the "fake" connection points explicitly, in this case they are moved in Visio 2010 along with the path as well. If you specify formulas (like it was done in the book) then Visio 2010 does not overwrite them when routing the connector (that was the difference). So I was wrong about Visio 2010 - it seems to behave even better in fact!

Note that the issue was actually not related to custom line ends at all, they just happed to be here by occasion.
If you are interested in the results, feel free to check out the attached drawing (no custom connectors, just that 3-segment thing). Just move the green box around the yellow one, and see how connectors change. Keep in mind, you might need to enable "Glue to geometry" to see how the border-glue works.

Jumpy, thanks again!