Author Topic: Create action to modify shape dependent on connectors glued  (Read 447 times)

0 Members and 1 Guest are viewing this topic.

michaelj1103

  • Newbie
  • *
  • Posts: 7
I was wondering if this would even be possible as there would need to be a couple moving parts to accomplish this task. See that attached picture before for what I am trying to accomplish.



Before I get into everything, my goal is to when doing designs/schematics, after connecting all the blocks I need for that design together, to be able to right click on a block (shape) and have an action that removes all the Inputs & Outputs within the block that are not currently connected to another block. Thus cleaning up the drawing and being able to fit more blocks onto a page.

I guess the first question to determine if it is possible is if there is even a way to determine if a connector is glued or not and if so base a function off of that.
Next step would be removing the text boxes and icons that are not glued. Then resize the middle box appropriately (to the same Y of the bottom text box), then reposition the "Location and Mounting Style shapes). And lastly, Update The Alignment Box. All while still keeping the connectors glued.

I've attached the visio file for reference of the blocks in the photo. I've also added "Adjacent Alignment Form" found from this site as I believe that may come in handy in repositioning the Input&Output fields (Atleast that is what I use to adjust them appropriately)

As you'll see, I've added the connectors to the Input&Output boxes and not the main group, so that if any of the text fields moved, the connector would move with it.

I don't have much experience with Macros/VBA (and I'm assuming that will be needed for this) so if anyone would be willing to help me out on this, it would be much appreciated!

Surrogate

  • Hero Member
  • *****
  • Posts: 1610
    • ShapeSheet™ Knowledge Base
Re: Create action to modify shape dependent on connectors glued
« Reply #1 on: June 13, 2022, 12:54:13 PM »
I don't have much experience with Macros/VBA (and I'm assuming that will be needed for this) so if anyone would be willing to help me out on this, it would be much appreciated!
As I know we haven't  opportunity define is connection poins connected via ShapeSheet. With VBA it is possible...

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3286
    • Paul Herber's website
Re: Create action to modify shape dependent on connectors glued
« Reply #2 on: June 13, 2022, 12:57:07 PM »
A few things that might cause some difficulties:
1. It will be a coding job, and not a simple one
2. It looks like your connectors connect to the outer box rather than the RJ45 shape
3. The input/output text is not related to the RJ45 sockets, except just nearby
4. None of the shapes have a suitable name so any code is going to be difficult
Electronic and Electrical engineering, business and software stencils and applications for Visio -

https://www.paulherber.co.uk/

michaelj1103

  • Newbie
  • *
  • Posts: 7
Re: Create action to modify shape dependent on connectors glued
« Reply #3 on: June 13, 2022, 02:12:07 PM »
Quote
1. It will be a coding job, and not a simple one

This is what I was suspecting. But I think I'm up for the challenge.


Quote
2. It looks like your connectors connect to the outer box rather than the RJ45 shape

Correct, the connectors location are on the outer box, but they are associated with the Input/Output shape. This is so that when Inputs & Outputs are duplicated when creating the block, the connection point will also be duplicated. I thought about adding connection points to the main group shape, but I didn't want to have to remove connection points every time I removed Inputs & or Outputs.
On another block I edited the shapesheet so that the connection points would stay in the same location regardless if the shape was extended in width (for longer Input/Output names, character length). I didn't include that in the above visio file.

Quote
3. The input/output text is not related to the RJ45 sockets, except just nearby

That is also correct, I did this so that when I added different "icons" (ex. HDMI, VGA, etc.) I could easily align the icons with ones below it and center it with the Input/Output text. This can be easily change to accommodate the VBA code. Would it be acceptable to just group the icons and Input/Output text fields together individually?

Quote
4. None of the shapes have a suitable name so any code is going to be difficult
Once the icons and text are grouped, I can name each one "Input 1", "Input 2", "Output 1", "Output 2" etc. Would this be sufficient? Or would it need to be more detailed and unique?


After doing those things, in my mind this is how the VBA code would need to be written.

Go through the Input/Output text blocks that have connection points and identify ones that do not have glued connections to them and delete the associated text box w/ icon.
Next starting with the lowest number Input # & Icon (ex. if Inputs 1-7 were deleted and Input 8 was the lowest number) Input 8 & Icon be moved to be bumped up next to the "Description" shape, but not aligned center to the "Description" shape, just the Y value.
Then the function continues to the next lowest number until all Inputs&Icons are arranged.
Then the function moves to the Output side and preforms the above function.
Once all remaining Inputs&Outputs are aligned, it would need to be determined what the lowest Input or Output field is. Then based on that value, the center box height would need to be resized to "Bump" up next to the farthest down Input or Output box.
Then, move the "Location" and "Mounting Style" boxes to bump up with the center box.
And finally, Update the Alignment Box.

A key thing I realize is that when aligning the different text boxes, their X and Y positions shouldn't be absolute, rather in relation to the group so that when the whole group is resized, it will also resize and keep the location of the shapes.

Thoughts on this? I'm up for the challenge and obviously it's a big one. Would love some guidance. Thanks!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4400
  • Ideas Visio-lized into solutions
Re: Create action to modify shape dependent on connectors glued
« Reply #4 on: June 13, 2022, 02:48:31 PM »
To get an idea of what can be done and coding involved, here's a development to create a shape with connection points and labels: 
http://visguy.com/vgforum/index.php?topic=7543.0
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 2984
Re: Create action to modify shape dependent on connectors glued
« Reply #5 on: June 14, 2022, 03:30:10 AM »
Automating the solution is fine, but may I suggest another approach?

Instead of handling code, you may set up a smart shape with the following features.
- a prop field defining the number of inputs and one for the outputs - eg "num_inputs" and "num_outputs".
- Connection points cannot be hidden, but you can for instance move them automatically to the bottom of the shape to show that they are not active.
- The plug icons would be sub-"smartshapes" of the main shape. with:
  - a list prop defining their type.
    This field would change the automatically the appearance of the icon and if wanted the label as well
  - a number defining whether the plug icon is shown or hidden. If hidden their width, height and pinY become 0, The hidetext field goes to true.

Simple yet effective. No code required.


Check the attachment.
To understand the shape, you need to inspect the shapesheets of both the main shape and one of the sub-shapes.
The relevant cells are the blue ones.


HTH, Y.
« Last Edit: June 14, 2022, 03:37:14 AM by Yacine »
Yacine