Author Topic: Visio connector  (Read 3168 times)

0 Members and 1 Guest are viewing this topic.

friesstefan@gmx.de

  • Jr. Member
  • **
  • Posts: 16
Re: Visio connector
« Reply #30 on: September 20, 2021, 04:12:34 AM »
Hi,
I'm just trying to understand how your code (wrapper) that you sent me works.
F8 step by step... as you told me.

Can you explain to me what you need the "user-defined cells" (User.dtName) for?
I see the new line in the ShapeSheet data, but I just don't know when it will be needed.

To understand the code, I added a 3rd shape.(Terminal) And change your code...


Sub GlueToPos (vShp1, vShp2)
vShape = "Terminal.35"  'I set the name of the new shape to the variable VSh2
...
BegCell1.GlueToPos vShp1, 1, 0.5
EndCell1.GlueToPos vShp2, 0, 0.5


I thought, that it would then connect the connector from PC to the terminal I added, but he didn't?

best regards
Stefan



friesstefan@gmx.de

  • Jr. Member
  • **
  • Posts: 16
Re: Visio connector
« Reply #31 on: September 20, 2021, 04:19:45 AM »
sorry
vshp2 ="Terminal.35" of course, not vShape...

friesstefan@gmx.de

  • Jr. Member
  • **
  • Posts: 16
Re: Visio connector
« Reply #32 on: September 20, 2021, 09:09:43 AM »
Hello everyone,
because of your help, I have now been able to implement my example.
I can now automatically connect all connectors to the workplace.

I also created a small example file of how it works now.

There are just a few little things left that I have to solve.
For example, I still have to specify the number of connectors that have to be linked. (external data)

However, I would need your help again very briefly.
Who knows the code which you can delete all connectors from the drawing sheet? (Even those who are already connected)

Thanks for help
Stefan


Surrogate

  • Hero Member
  • *****
  • Posts: 1389
    • ShapeSheet™ Knowledge Base
Re: Visio connector
« Reply #33 on: September 20, 2021, 09:49:55 AM »
Hi, Stefan !
Who knows the code which you can delete all connectors from the drawing sheet?
This code can look like this
Quote
Sub DeleteAllConnectors()
Dim shp As Shape
For Each shp In ActivePage.Shapes ' iterate all shapes per active page
If (Not shp.Master Is Nothing) Then ' check is shape have parent master
If shp.Master.Name = "Connector" Then shp.Delete ' if parent shape name is "Connector" delete shape
End If
Next
End Sub

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4090
  • Ideas Visio-lized into solutions
Re: Visio connector
« Reply #34 on: September 20, 2021, 10:11:55 AM »
Quote
Can you explain to me what you need the "user-defined cells" (User.dtName) for?
I see the new line in the ShapeSheet data, but I just don't know when it will be needed.

This entry is where a workstation name is placed.  It is how you identify one workstation from the others.  Your Excel data file would provide the names, e.g., WS1 connected to WS97.

For example, let's say the external data file lists WS1 25 times.  That is, it connects to 25 other workstations and needs 25 Connectors.  The initial code I provided needs editing and begins to get complicated.  You don't want to have 25 copies of the WS1 workstation.  So, the code, before dropping any workstation, should search the shapes on the page to check if any shape has that name.  If so, it uses that shape, assigning it to the appropriate vShp1 or vShp2, rather than dropping a duplicate copy.  Code-wise, it requires a loop to search all of the shapes on the page, exams each for existence of indicated name by using resultstr, if found, skips dropping that shape, otherwise, drops a new shape. 

You can also create additional  User Defined entries, same technique, or, perhaps to, say, different shapesheet sections.  Perhaps to store utilization as a shape property (shape data). 

Quote
I'm just trying to understand how your code (wrapper) that you sent me works.
F8 step by step... as you told me.
The way the wrapper sub is just an ordinary macro.  Unique only in that it runs first and calls other macros in the correct order.  It could have additional statements preceding, between, or after each Call.  The Call causes the code to jump to the indicated macro, which executes and upon completion returns to whence it was called.  The code then continues with next line.  All of that should have been revealed using <F8>.

Quote
Who knows the code which you can delete all connectors from the drawing sheet? (Even those who are already connected)
You can modify the delConns macro.  After the code checks for OneD shape, there is a subsequent IF statement construct that checks for number of connections, you could merely change that to <=

Updated on  9/20/2021 at 01:00:26 PM
Alternatively, use code that Surrogate provides.  Surrogate's code made me realize that my code needed additional update such that only Dynamic connectors are deleted.  The code has been updated.  Likewise, his code needs updating too.  Because Visio re-assigns shape ID's after each deletion, his loop must be modified to start at lst shape ID and work backwards by 1, as I have shown in the delConns macro. Secondly, the Master name needs to be changed from "Connector" to read "Dynamic connector".  With updates, both codes will delete only Dynamic connectors.



« Last Edit: September 20, 2021, 01:03:04 PM by wapperdude »
Visio 2019 Pro

friesstefan@gmx.de

  • Jr. Member
  • **
  • Posts: 16
Re: Visio connector
« Reply #35 on: September 20, 2021, 12:34:55 PM »
Danke an alle Beteiligten für euren großartigen Support. ;D ;D ;D ;D ;D ;D