Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: jmw_visio on February 06, 2016, 11:54:14 PM

Title: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 06, 2016, 11:54:14 PM
Hi
Trying to create a connector that only goes vertical or horizontal.
I have played around setting EndX and EndY Based on a variable I have set up that is N,S,E,W

I would like to set this Direction based on the Begin Glue to an Object.

But I don't know where to begin to find that kind of info so I can redirect.

Any ideas or another approach?

Thanks
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: JuneTheSecond on February 07, 2016, 04:53:49 AM
Try to search in web.
There are many articles how to make yore own connectors or shapes.
For example https://support.office.com/en-us/article/Create-a-custom-connector-48f47591-b9d5-4e6f-9203-5b34ce09a5e9
Basically connectors are not much different from shape.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: Yacine on February 07, 2016, 08:36:58 AM
@Junichi, Why did you not recommend your latest 1D shape with fixed angle?

@jmw, I wonder how this connector is supposed to work.
What should happen, when the shapes are horizontally so far apart that their horizontal projections do no intersect?
Guess you'd better stick with Junichi's advice and use a line, instead of a connector.
Search the forum for his posts.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: JuneTheSecond on February 07, 2016, 12:37:36 PM
Ah! Now I understand your request to connector.
Your request is far higher than that of beginner.
The connector has to work like a kind of machine element.
Horizontal connector has to fix relative y-coordinate of connected two shapes.
I wonder if it is realized only by a special horizontal connecter.
If it is possible kinematic machinery simulation may be realized with Visio.
It may be a very big challenge for Visio.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 07, 2016, 02:08:44 PM
Thanks for the replies!

Actually I guess I should describe a little bit more.

Basically the most important part of this connector is to attach the 1st side to an object. The other side will not connect to a shape so I want it to move in relation to the connection shape and go away from it.

The other end of the connector will have a small circle with label in it.

I will then use another connector based on the Dynamic Connector and connect it to the circle/label and the other side to a shape.

I have used the great labelled connection I saw in a few articles. But then thought I would like to create a one to many connector. After reviewing varying issues I decided it would be easier to make a connector for one side "the one" and then just connect multiple connectors to it "the many"

So to sum it up, when I connect this to a shape I basically want to move it away from the shape. If I connect to the left side I want it to go left. If I connect to the top, I go up. If I connect to the bottom, I go down, and if I connect to the right, I go right.

Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 07, 2016, 02:26:35 PM
Until I figure out how to insert images, here is a Visio 2013 drawing with my shape at this point.
With comments to help describe objective.

Thanks
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 07, 2016, 02:27:19 PM
Also, how do I insert images into a message? I see the insert image which gives me http img tags.
If I have some screen captures saved what do I put in the image tag?

If I can give some screen captures of the shapes and shapesheet equations it might be easier to follow.
Thanks
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 07, 2016, 02:37:27 PM
Yes Yacine, actually I did create this with a line.

This whole connector thing gets me confused.

To create the shape
I created new master, added a line, grouped it, then added the label inside the group.
Added the lines Geometry to the group shape, made the group 1-D, then deleted the line.

Which I will have a question about after I get thru this hurdle, LOL.
Basically the art of getting multiple objects on a shape but not have it show up as a big group block when dropped. Like it to just show the connection and its points. I guess that is 1-D? If I try and take the Dynamic Connector and add a shape to it, I lose that. The labelled connector I found uses the Dynamic Connector with extra shapes but when dropped it still looks like a regular Dynamic Connector.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 07, 2016, 03:01:40 PM
Just got thru looking at your INCREDIBLE Isometric Shapes Yunichi!

So much to digest! Unbelievable great stuff!

I noticed your 'Continous Number' Stencil.

Basically that is what I was trying to create. Except yours points to the connection point where mine points away at the label. So basically that is the shape I want except I would love for it to automatically flow away 180 away from the connection point relation to the connected shape.

Currently I have shape data fixed list of N;S;E;W and I select which direction to go. But would love to automate this based on the connection location.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 08, 2016, 11:39:52 PM
Ok, After testing some today, I discovered turning ObjType to a 2 is my friend. This turns on routing, etc. and so when I connect the X Endpoint to a shape, it routes the connector away from the object. I then can tell what direction I need to go by looking at the first 2 Geometry point X1,Y1 and X2,Y2. Now to get the connector to bounce to that direction and a specified length, I just need to adjust the EndXX,Y cells.

Now to figure out best way to monitor the X,Y changes and react and set EndX,Y

Looking at possibly using the EventXFMod and calling a subroutine to do the code above.

Firing a sub from it successfully and Debug.Print the name. Now to determine how to filter certain events so that I am not firing at every moment since EventXFMod is firing 5 or more times every time I move the X Endpoint.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 14, 2016, 03:48:25 PM
I'm back! LOL

Ok, after a few days of reading thru lots of great post on here, I found one this morning that really helped.

http://visguy.com/vgforum/index.php?topic=4689.15

To give you a hint of where I was before finding and how happy I am to find this function let me explain.

Basically trying to get a connecting ray (Straight) that shoots away from the shape its connected to.

But couldn't figure how to detect which way to go away from shape.
I figured out that if I set the connector to Dynamic, Visio draws it away and I can use the first two X,Y points and determine N,S,E,W. Then could figure out where to place my EndX,EndY. then set back to Straight.

But due to certain timing and other logistics, was a big pain.

Well this morning I saw the post above that mentioned some undocumented functions.

_UCON_BEGTYP

This function, when give the BeginX,BeginY,EndX,EndY, and a couple other things for good measure returns 2,3,4,5 for the different directions.

So now I don't need to set to Dynamic and back to straight. I can now set my EndX,Y with one shots when the direction changes.

Here are the formulas I did for testing this morning.

I have created a Prop.BegConn  =_UCON_BEGTYP(BeginX,BeginY,EndX,EndY,BegTrigger)+EndTrigger*0

This gives me 2,3,4,5 which I can then use to set the End Points.

I then have the following setting them!

Prop.North =IF(Prop.BegConn=5,SETF(GetRef(EndX),BeginX)+SETF(GetRef(EndY),BeginY+1),FALSE)
Prop.South =IF(Prop.BegConn=4,SETF(GetRef(EndX),BeginX)+SETF(GetRef(EndY),BeginY-1),FALSE)
Prop.East =IF(Prop.BegConn=3,SETF(GetRef(EndX),BeginX+1)+SETF(GetRef(EndY),BeginY),FALSE)
Prop.West =IF(Prop.BegConn=2,SETF(GetRef(EndX),BeginX-1)+SETF(GetRef(EndY),BeginY),FALSE)

Works great!!!!!
Love googling thru this forum. I have downloaded so many projects and favorited many of the discussions.

The SETF(GETREF   was learned from one.

I am currently taking a Connection with labels and adapting to my needs!

So thanks to all for making this a vibrant community.

As soon as I wrap this up into my connector, Ill post.

My connector is basically a Labelled Connector with the connection line hidden as it crosses the drawing. Calling it an On-Sheet Connector. I am using a very nice one but it was a dynamic one to one. I want a one to many. So my idea is to have a From Connector which is the "one" and why I wanted just a short ray coming from the shape. Then I will have a To Connector which I will be able to attach several to the label for the From.

Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: Yacine on February 14, 2016, 06:30:40 PM

Guess this would be a good reading:
http://visualsignals.typepad.co.uk/vislog/2015/04/building-a-labelled-dynamic-connector-in-visio.html
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 14, 2016, 06:44:34 PM
Yes Yacine,
That's basically where I started!

Added an option for a circle label, and an arrow on the from connection side.

Then I started thinking of how to attack the one-to-many issue.

That connector is a work of art, beautiful and very inspiring!

Thanks for posting the link, I forget how many things I have looked at.

I will be using that connector as the major basis for the "many" To Connectors.

His connector is a dynamic connector and he hides the middle section of the connector with a different Geometry Section. Very clever!
Title: On Sheet Connector To - Master First Pass
Post by: jmw_visio on February 16, 2016, 08:43:09 PM
Here is a first pass on the master element

Basically 2 modes Normal where the label shoots away from the connected shape and horizontal where N and S connectors turn horizontal
Various User Settings are Different Shapes for the Label and ability to change connector lengths
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved
Post by: jmw_visio on February 17, 2016, 05:38:28 PM
Ok Here is a Second Pass

2 Masters Now
On 'Sht Conn To' and 'On Sht Conn From'

Basically The "To" is the One of the One to Many and the "From" is the Many of the One to Many.

The dwg has one "To" on the left side and three "From" on the right side.
The bottom has the same except I turned on the connectors so you can see how they are connected.

One Note I found another method to determine connection path at the beg and ends.
ANGLEALONGPATH(Geometry.#.Path, 0) is the Beg Point
ANGLEALONGPATH(Geometry.#.Path, 1) is the End Point

I am using this in the From Master to determine how to move my Geometry Section 2 (The lone label and connection points)

I have a connlength for the From arrow so you can specifiy the From Arrow Line. The dynamic connector often choses something a lot shorter like 0.2 inches. You can see that on the dwg when I turned on the whole connector line. Would love to make it go to this connlength also, but with it being the end of the geometry sections, its hard to set them. Any ideas would love to hear them.

Next going to program the ability to sync the Label ID, etc from the To Master to the From Masters.
And add some more text desc fields for display if more info needed.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: Yacine on February 17, 2016, 07:08:03 PM
Hi jmw,
just to give you some feedback - which you deserve for posting so much. ;)
It is not obvious to the user what the primary shape is, so you need to explore the drawing and need to remember the chain sorting.
Synchronisation did not work for me.
Otherwise, GREAT JOB. Please continue working on this.
Cheers,
Y.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 17, 2016, 07:36:10 PM
Thanks for the review!
Yes, the synchronization stuff is still John Goldsmith settings, I removed the two lablels that used it, so its broken right now, I left the prop in because he had a lot of nice user interface stuff setup. Since his is just one master its easy to reference the other Shapes Label Info thru Sheet References to transfer.
I plan on using the setting to transfer down from the Connected Shape and To Master across to all the From Masters connected. So if you set the To ID to 5 it will then make all the Froms connected 5 also.

I dug up some code a week ago that showed how to transfer the info along the glued connectors Shapes on each end. I now just have to go dig that back out and see if I can get that working. The idea is the shape at the beginning to have a couple data fields and when connected they are passed down to the From Connector.

I also have a dialog on drop that has options for numbering. Basically incrementing to the next number from the highest on the page, using an available gap say the current numbers are 1,2,5,6  it would use 3, and also the ability to reset all numbers to clear out any gaps.

I am also going to add some more generic text fields. I know the network guys love to include multiple address's, ports, etc.

Then I will also try and polish the interface more like Johns nice right click menus, etc.


Then my next big attack is Off Sheet Connectors. I played around some with the included one but since it uses canned code I cant get to, I figured rolling my own will allow more data transfer also.

Thanks for the time to review

Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 18, 2016, 06:35:00 PM
Ok Yacine,
Here is my first pass at synching the IDs.

Basically created a sub that runs off of the Glue BegTrigger.

It fires a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! So I put some code to limit the amount of activity.

First I verify the shape is the currently selected one. I don't know why it fires for all the shapes instead of just the one I am gluing?!?!?!?
Second I use/store a copy of the BegTrigger field so I can see if there has been a change to what was glued. Works great for comparing when I change from one object glue to another. But if I disconnect the glue, the 2 never match to knock me out of the loop. Basically the BegTrigger has a reference to itself and the BegTrigger shows the _XFTrigger(MasterShapeName!EventXFMod) while when I store this to the User.BegGlue I get just _XFTrigger(EventXFMod) so that comparison is always false.

I got around this by just checking if the User.BegTrigger Value is a 2. If so I reset if its  then a 1 then I don't need to

When I do detect a new glue or unglue I set the User.ToID to be linked to the To Shape from the Connection. I then create a User.SetID which monitors and sets the Froms ID to the User.ToID if it changes.
On unglue I try and clear them.

On Page 2 I have set up a shape that has two 'To' connectors with diff IDs (1,2). I then have a shape with a 'From' connector ID of (0). If you select the 'From' connector you can move the Beg Point to the two connectors or unglue. The IDs should follow.

Would love for you to review.

Thanks
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 18, 2016, 08:55:02 PM
Yacine
On this version I tried to address your comment "It is not obvious to the user what the primary shape is, so you need to explore the drawing and need to remember the chain sorting."

Basically I rolled a poor mans selection sub using the events.

When a "From" Connector is selected the full connection becomes visible all the way back to the beginning connection.
Then upon deselection it hides again, unless being overridden by HideMidLine setting.
Still bugging it out, everynow and then get a selection error, but works pretty good.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 19, 2016, 04:02:15 PM
Latest Version
Added a third geometry section for the status indication going back to the Begin Glue when selected. The base geometry section (1) had a habit of changing direction at 1/2 the distance to my label making it look a little weird.
I now have Geometry1 turned off at all times. The geometry3 is now from the label back to the begin, straight. Basically because I just programmed in 2 X,Y Points.
Would like to get it to do routing also, but not sure how to program the Geometry to do this.

Of course upon adding the third Geometry Section the issue with Selection Errors is a little worse, LOL.

Trying several things like Group, Selection properties but no luck. Asked for some ideas in the programming section.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 19, 2016, 05:54:13 PM
Latest Version
Added some HMI Enhancement's

Changing the ID on "To" Shape changes the "From" IDs when Synced
Changing the Shape on "To" Shape changes the "From" Shapes when Synced
Right Click Shape Menu
Right Click Horiz Only
Double Click Open Data Props Dialog


Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 19, 2016, 09:08:34 PM
Ok I promise I am not trying to become "Hero Member" with this one thread, LOL!

On this version I have added a right click menu option to the "To" Connector "Add New Connection"

When you click it, a new "From" Connector is dropped on the page and connected to the corresponding "To" connector.
You can then pick the end glue point at the end of the arrow on the "From" and connect it to a shape.

On the Page 2 of this doc, I have placed two rectangle shapes. I have connected a "To" connector on the left shape. If you Right Click Add New Connection, a new "From" is dropped. then connect that glue to one of the sides on the rectangle on the left.
The you can repeat this 3 more times and connect them to each side of the rectangle on the right.

So we now have a "One to Many" Connector Shape System.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 19, 2016, 11:32:46 PM
Ok,
one more beta for the day.

I have now made it when you select a "To" Connection all the "From"s connected will highlight.

Of course my invalid selection identifier is really pissing me off now! It happens all the time now.
You cant a stick without 10 of them popping up!
Guess I will try to debug it out this weekend.

Hoping someone has some ideas from my post on it in the Programming section!

Cheers
Mike
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 20, 2016, 03:59:21 AM
Ok, got the invalid selection bug fixed by checking to make sure there is at least one item selected.
It was in a different Sub from the one where I do the Selection work so I didn't realize it was running.

Here is a version of the masters without the annoying error.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: Yacine on February 20, 2016, 09:08:34 AM
Amazing.
But still some bugs.
Adding a connection requires a stencil, you hard coded. The code is better kept in this stencil, this makes deploying easier.
Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: jmw_visio on February 20, 2016, 02:25:59 PM
Thanks for the review Yacine.
Yes, I am just in the testing phase. Just adding code to get jobs done and will probably redo from scratch once I get everything I would like to fit it.

Was just starting to decided how to handle the code/stencil/distribution part.

New to Visio development.

I of course would like it to be distributed easily.

Since it is two master shapes, I figure a stencil is the easiest distribution method.
Will be trying to work on moving code to the stencil.

Any advice/ideas on this from you guys would be great.

I think moving the connection logic Sub into a Stencil will be easy.

But the Event code Subs are a little more Visio specific so not sure I can move them.

Any ideas on what to do with those subs would be greatly appreciated.


Title: Re: Line Connector Horizontal or Vertical Only Not Diagonal or Curved [Solved]
Post by: Yacine on February 20, 2016, 09:20:08 PM
Not sure about this, but I think you need to implement a variable that stands for the page (or the document?).
This can be done by either starting a macro from the stencil manually , or on load. Mind that the variable is lost when the macro crashes.
Then you can set up an event catcher (selection changed) and do the stuff that needs to be done.