Visio Guy

Visio Discussions => General Visio => Topic started by: hamohd70 on July 04, 2020, 06:20:18 AM

Title: Changing Connector with line
Post by: hamohd70 on July 04, 2020, 06:20:18 AM
I have a complicated drawing create by a friend and used connectors in it. The problem I'm facing is when I try to group and rotate the shapes, the connector lines get messed-up.

Can I change connectors with line in in one shot- may be using VBA!

an example is here ..
(https://www.mediafire.com/convkey/d301/876mhukpzv8yijn6g.jpg)

it become like this..
(https://www.mediafire.com/convkey/f86a/vqymm70imr4diea6g.jpg)
Title: Re: Changing Connector with line
Post by: Yacine on July 04, 2020, 08:05:00 AM
You could, but that would be pitty for the connectors. Try resetting the connectors. https://support.microsoft.com/en-gb/office/reset-the-path-of-a-connector-881e9ea6-f54a-4708-a0de-c42e24f33cac

If you still want to transform them into lines, use the join function https://docs.microsoft.com/en-us/office/vba/api/visio.selection.join
Title: Re: Changing Connector with line
Post by: Croc on July 04, 2020, 08:54:22 AM
You can also group multiple shapes. When you rotate the group, the configuration of the connectors within the group will remain unchanged.
Title: Re: Changing Connector with line
Post by: hamohd70 on July 04, 2020, 12:39:06 PM
Quote from: Yacine on July 04, 2020, 08:05:00 AM
You could, but that would be pitty for the connectors. Try resetting the connectors. https://support.microsoft.com/en-gb/office/reset-the-path-of-a-connector-881e9ea6-f54a-4708-a0de-c42e24f33cac

If you still want to transform them into lines, use the join function https://docs.microsoft.com/en-us/office/vba/api/visio.selection.join

This solution worked. Thanks.
Title: Re: Changing Connector with line
Post by: hamohd70 on July 04, 2020, 12:40:34 PM
Quote from: Croc on July 04, 2020, 08:54:22 AM
You can also group multiple shapes. When you rotate the group, the configuration of the connectors within the group will remain unchanged.

Unfortunately this did not work without the first solution.

Thanks.
Title: Re: Changing Connector with line
Post by: wapperdude on July 04, 2020, 03:20:11 PM
@Croc:  Not true.  Grouping does not fix this problem.

@All:
This connector re-routing thing has been a long time nuisance.

There are two things that will minimize / eliminate the problem.  Unfortunately, there's no global setting, and is on a per connector basis.  It can also involve all shapes that "participate" in the rotating scenario.  These steps include:
  1) Each connector must have its routing behavior set to As Needed.  Developer tab>Shape Design>Behavior>Connector tab>Reroute cell.

  2) Connectors must be glued to shape via literal connection points.  "Walking" glue does not elicit desired behavior.

I've attached a sample drawing to show.  The connectors are set to "freely" reroute.  There are 3 macros which can be run to change the behavior.  The main routine is RunRcsv.  It calls a 2nd sub that literally iterates thru every shape on the page, including subshapes of groups.  As this 2nd macro runs, it calls a 3rd macro that does the actual changes.  Thus, other or additional macros can be run to do other things.  Presently, just the one which changes the connector re-route property to "as needed" for EVERY connector on the page.

Here is the code:

Sub RunRcsv()
' This is the initiating macro, gets the page shape collection
' and calls ShapesColl2 recursive subroutine
' RcsvSrch calls sub to do desired changes
   RcsvSrch ActivePage.Shapes
End Sub

Private Sub RcsvSrch(ByVal shps As Shapes)
   Dim vShp As Shape
   For Each vShp In shps
       If vShp.Shapes.Count <> 0 Then RcsvSrch vShp.Shapes
       Call CnctrProp(vShp)
   Next vShp
End Sub

Private Sub CnctrProp(visShp As Shape)
    Set vShp = visShp
    vShp.CellsSRC(visSectionObject, visRowShapeLayout, visSLOConFixedCode).FormulaU = "1"
End Sub
Title: Re: Changing Connector with line
Post by: Croc on July 04, 2020, 04:31:27 PM
Quote@Croc:  Not true.  Grouping does not fix this problem.
And in Visio 2007 it works :)
Title: Re: Changing Connector with line
Post by: Croc on July 04, 2020, 05:31:20 PM
wapperdude, do you know if Microsoft recognized this bug?
One of the main properties of the group is to isolate incoming shapes, to act as an intermediate parental level. Coordinates must be calculated within a group without regard to its movement or rotation. And this property has stopped working in recent versions of Visio.
Title: Re: Changing Connector with line
Post by: wapperdude on July 04, 2020, 05:36:15 PM
Really?!?  Very strange.   

My memory must be whacky.  Seems as far as I can recall, that has always been a problem.  Even with V2007... which, until recently, was my favorite version.  Sigh. 
I cannot go back and try.  Perhaps I'm remembering V2010 which was what was used at work???  Apologies. 

Unfortunately, I have no idea what M$ does.  Perhaps Visio Guy or Paul Herber.  I'm too low on the food chain.