Author Topic: Stretch Smart Shape & preserve properties & automagically add connection points  (Read 898 times)

0 Members and 2 Guests are viewing this topic.

The Walrus

  • Newbie
  • *
  • Posts: 6
Hello,

I'm a relative Visio newbie, thrust into the environment for reasons of cost savings.  Overall, I'm making the transition fairly well but, like any good engineer my ultimate goal is to become really, really lazy.  To that end, I'll expend great amounts of effort to get there!

We are currently using Visio13 for electrical system schematics.  90% or greater of our drawings are for interconnections black boxes together with wires and cables.  The Powers-that-Be have determined that our previous CAD package was too expensive to maintain, and that Visio would suit our needs at a fraction of the cost.  Mostly, they are correct.

Now to the crux of my problem.

In our drawings, we are often having to resize shapes (i.e. electrical connectors). The default behavior in Visio tends to be that the connection points move based on proportion of the shape rather than on grid or with defined spacing.

I would like to build/create a smart shape that started off as two pins, but that the user can stretch or collapse as required in their drawing, while automatically inserting/removing connection points corresponding to the grid.  I've attached a sheet to hopefully demonstrate more precisely the desired effect.

This thread seems to maybe cover the collapsing behavior to some extent, but I'm not sure that's the right approach for what I need.

Any help would be greatly appreciated!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3100
  • Ideas Visio-lized into solutions
Here are some things to help you on your way...
http://visguy.com/vgforum/index.php?topic=6314.msg31942#msg31942

See attached for "expanding/contracting" shapes.

Wapperdude

Visio 2007 Std

The Walrus

  • Newbie
  • *
  • Posts: 6
I have spent an awful lot of time not getting very far.  I think my trouble is truly understanding how the properties in teh shape sheets interact.

So, perhaps I need to back off a bit and start more simply.

Looking at the VSD in my OP, I think I'd just like to start simply with being able to stretch a shape and have it preserve some certain dimensions.  See C & D in that VSD.

I'll then build from there.

Are there any decent tutorials somewhere that are specific to just being able to create a 'stretchable' shape that preserves certain dimensions?  Like maybe with an arrow that preserves the size and ratios of the arrow head when stretched?

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3100
  • Ideas Visio-lized into solutions
Sorry about the confusion.  Attached is a simpler shape.  This demonstrates the basics of stretching a shape between some minimum value and maximum value in discrete steps using the bound function.  As the shape expands or contracts, connection points are "added" or removed" as is appropriate.  Note, no connection points are eliminated, the unused ones are merely stacked on top of each other.  It would require code to reduce or increase the number of connection points as that would require eliminating or adding lines to the Connection point section of the shapesheet.

HTH

Wapperdude
Visio 2007 Std

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3100
  • Ideas Visio-lized into solutions
Here's another version, this uses a fixed list to choose the number of connection points.  Dbl click the shape to bring up the shapedata, select the number of connection points, and enter the desired pin to pin spacing.  The shape will automatically size based upon those settings.

Wapperdude
« Last Edit: November 04, 2017, 11:24:26 PM by wapperdude »
Visio 2007 Std

The Walrus

  • Newbie
  • *
  • Posts: 6
I'm back, and I've not been able to accomplish any of my desired traits in this thread.  So I'm going to back way off to baby steps.

Step 1.

I would like to build a shape in Visio, and when I stretch it or contact it, I want both ends of the shape to maintain their dimensions.  At this point I am not at all worried about connection points.  I just want the shape to act as a 'smart shape' as in this article.  I can stretch the arrow as much as I want, but the arrow head itself stays the same.  I want to learn how to create this functionality for my shapes (that aren't arrows).

What properties allow me to do this?  Where in the ShapeSheet or elsewhere do I need to go to make this happen?  The Shape Design --> Behavior or Shape Design --> Protection dialogs seem like they should be helpful, but they are not.

I tried using the arrow stencil from General --> Blocks, and opening the ShapeSheet, but I can't seem to find anything that 'locks' the arrowhead dimensions in place.

Please help!
« Last Edit: April 12, 2018, 10:49:39 AM by The Walrus »

Yacine

  • Hero Member
  • *****
  • Posts: 2381
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3100
  • Ideas Visio-lized into solutions
Wrt shape stretching, this article directly covers the topic:  https://msdn.microsoft.com/en-us/library/aa200966(v=office.10).aspx.  It is part of a very comprehensive discussion based upon V2002.  Everything in this entire article, some 28 chapters, is excellent foundational information.

Enjoy!
Wapperdude
Visio 2007 Std

The Walrus

  • Newbie
  • *
  • Posts: 6
Yes, both of these posts are VERY helpful!

The Walrus

  • Newbie
  • *
  • Posts: 6
So, thanks to the posts on the 12th, I have made some great progress!  I have been able to use the Geometry section to create a smart shape with the behavior I would like.

Now, on to the connection points.  I've attached a vsd with the shape I've created, and I've added a few connection points that behave as I would like.

Now, I'm looking to add the connection points automatically.

I'm fairly adept at writing excel functions, and it seems that Visio uses a lot of the same functions, but even more.

I'm thinking there ought to be a way to add connection points automatically based on a function of the height.  Perhaps test for height, and divide by distance, and the result is N.  For every N, place a connection point.  Am I barking up the right tree?

Take a peek at what I have so far and feel free to critique.

The Walrus

  • Newbie
  • *
  • Posts: 6
I'm getting very much closer, but it appears that I need to run a Macro to get the connection points to work properly.  I haven't written code in ages, and I'm not sure how to call aspects of the shape sheet into Visual Basic, so I would appreciate any help in that arena.  I think my logic is right, or at least right enough to get where I want to go, but syntax is where I'm stuck.

Code: [Select]
Sub AddConnPts()

Dim I As Integer    'Incrementer
Dim N As Integer    'Number of Connection Points Needed
Dim C As Integer    'Number of existing Connection Points
Dim H As Long       'Height of Shape
Dim HString As String   'String to put in Connect points Y Column
Dim WString As String  'String to put in Connect points X Column

Get Shape NameID            'Don't know how to do this
    Get shape Height = H    'How to get height off shapesheet for NameID
        If H > 0.5 Then
            N = (H - 0.25) / 0.125           'Sets number of needed connection points based on geometry of shape
            Get Existing Connection Points = C  'How to count the number of existing connection points on NameID
            If C < N Then
                For I = C + 1 To N
           
                HString = "IF(Height*1>=0.5,Height*1-0.125*" &I ",0"   'how do I put this in the Connection Points area of Shape Sheet?
                WString = "Width*1"
               
                'How to insert strings in next incremented row of Connection Points section of shape sheet?
           
                Next I
            End If
        End If

End Sub
My intention is to add an Actions section into the part shape sheet and create an "Add Connections" Menu option for the shape that would then run the macro.

Any and all help is greatly appreciated!