Visio connector

Started by friesstefan@gmx.de, September 15, 2021, 11:13:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

friesstefan@gmx.de

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

sorry
vshp2 ="Terminal.35" of course, not vShape...

friesstefan@gmx.de

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

Hi, Stefan !
Quote from: friesstefan@gmx.de on September 20, 2021, 02:09:43 PM
Who knows the code which you can delete all connectors from the drawing sheet?
This code can look like this
QuoteSub 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

#34
QuoteCan 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). 

QuoteI'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>.

QuoteWho 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.



Visio 2019 Pro

friesstefan@gmx.de

Danke an alle Beteiligten für euren großartigen Support. ;D ;D ;D ;D ;D ;D