Author Topic: are there similar examples  (Read 8992 times)

0 Members and 1 Guest are viewing this topic.

perry59

  • Full Member
  • ***
  • Posts: 216
are there similar examples
« on: July 18, 2013, 03:37:00 PM »
are there similar examples for what I want to do?
and that is this:
I want to create a very simple shape, just a tall narrow rectangle with some circles inside it (this will represent a "bus bar").
however, when dragging this shape onto the drawing I would like the user to be prompted how many terminals it should have (the circles) then it would elongate itself to accomodate that number of evenly spaced circles. Also, it should prompt if this is a full bus or a partial bus. The partial bus will have a jagged bottom to indicate a break.
I guess this would be a "smart" shape with some enhancements to the shape sheet.
are there any examples that might get me started?
thanks

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: are there similar examples
« Reply #1 on: July 19, 2013, 01:26:22 AM »
Here was a thread recently about a ladder or fence shape where the number of rungs(?) or fence posts depended on the length of the shape. One possible solution was to use a Fillpattern to generate the circles.

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #2 on: July 19, 2013, 10:14:24 AM »
Well, I'm part way there. I have a "bar" which grows in length depending on a value in custom properties.
I just don't know how to copy or array my circle object based on that value. Is it even possible? If that is not possible, could I draw all the circles into my grouped shape and hide a number of them based on the aformentioned value? How could this be done?
(did a search for "ladder" and "fence", didn't find anything)
« Last Edit: July 19, 2013, 10:16:28 AM by perry59 »

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: are there similar examples
« Reply #3 on: July 21, 2013, 02:58:48 PM »
Here's an article about line patterns. Fill patterns work similar to that:

http://www.visguy.com/2008/03/03/release-the-power-of-visio-custom-line-patterns/


The other method is your suggested one:
- Give Bar shape a userdefined cell: User.Circlenumber.
- Place a formula in that cell, that calculates the number of visible circles depending on the length of the shape or the value in your ShapeData property, that defines the length.
- Draw the maximum number of circles you need and group them to your bar shape.
- Give each a custom property or user defined cell with it's number/position, for example User.Number.
- Make another userdefined cell: User.Visible.
- Inside a formula ala =(Sheet.123!UserCirclenumber>=User.Number)
- where Sheet.123 is the name of the group shape / bar shape.
- That formula is true when the number of needed circles is equal or bigger than the number of the actual circle.
- In Shape geometry of circle shape,in NoShow cell place a formula =not(User.Visible) to hide the shape, when number of needed circles is lower then the shapes number.
- Place a formula in width-cell that places the circle on position one when invisible and on position n when visible, ala:
 =10mm+If(User.Visible,(User.Number-1)*5mm,0mm)
- Above formula places the first circle at 10mm and ever other circle 5mm after the previous one.

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #4 on: July 22, 2013, 12:11:38 PM »
Thanks for the info Jumpy!
hope to get a chance to try that out this afternoon. Will report back on progress.

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #5 on: July 23, 2013, 10:51:21 AM »
Its getting there!
The number of circles (terminals) increases or decreases when I change my "number of terminals" property, so thats cool. I just need to come of with a formula to evenly space them within the confines of the rectangle (bus) and it needs to be relative to the height of the bus in case the user stretches it. (that number is in the "Piny" cell) For that reason I did not use the last portion of jumpy's suggestion (I also saw no reason to move the circles into position on a change in the bus height, just making them visible seems to work fine, and why is it in the width cell?).
One thing that is giving me a hard time now is adjusting sizes, whats up with visio here? \
for example, my formula for the height of the bus is "terminal count +1", so if termina count is 1 then the bus size should be 2 (this is in inches BTW). But the bus is only 1 inch, and with each increase in the number of terminals, instead of growing by 1 inch, it grows by only a half inch. What the heck???

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: are there similar examples
« Reply #6 on: July 23, 2013, 01:02:19 PM »
Visio shapes are typically based upon width and height units.  So, shape sizes are multiples of these numbers.  If the initial width and height are correct, then, incrementing the shape in terms of multiples of these numbers should produce the desired result.  Note, these changes are typically done in the Geometry sections.

Another approach to building this shape is multiple geometry sections -- one for each circle.  Each geometry section would have the circle pre-placed in the desired location but it's visibility would be toggled off.  The rectangle would be an additional section, and it's dimensions controlled by the number of circles.  Some Visio shapes use this technique.

Other precautions that you might want to consider to prevent your shape from getting tweaked:
1.)  put a guard function around the width, height numbers.
2.)  in the Protection section of the shape sheet, you might want to set the LockCalcWH cell to 1.

Wapperdude
Visio 2019 Pro

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #7 on: July 23, 2013, 02:29:59 PM »
Yes, I realizied that when my grouped shape was at its smallest formula size (terminal count +1) the shape was an inch too short. I physically drug the shape to the correct length and after that it increased/decreased length as expected :)
I am not familiar with geometry sections, are there some examples I could look at?
as far as protecting the shape, I want it and its contents to stay the same relative to one another, but I would like to be able to drag/resize the shape. Is this possible?

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: are there similar examples
« Reply #8 on: July 24, 2013, 01:25:34 AM »
First: I'm sorry for the confusion with the formula in the width cell. It should have been the PinX cell.

The reason why I suggested placing the circles in a different place when invivible is, that otherwise (if the circles always stay at their position) they are outside of the boundaries of the shape, when the shape is small and the circles are invisible.

There are for example VBA-functions out there, that could be confused by that.

As for protecting your shape:
You could for example only protect the width of your shape, so it can only resize in x-direction with your formulas, but you can leave the height without guard, so you can manually resize it.
If you don't protect PinX/Y, dragging is still possible.

If you get better with the shapesheet, you could for example allow the manual resizing of the width, too. With formulas in the shapesheet, you could adjust the shape after the dragging, so the width can only get values, that are multiples of a certain basevalue. And depending on the width you could than calculate your circles.

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #9 on: July 24, 2013, 02:19:35 PM »
the position of the circles are determined by a formula, so as the shape gets smaller the circles get closer (and some disappear)
I also locked the aspect ratio of the group, so if you drag to make it taller, it gets wider as well, the circles also change size.

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #10 on: July 24, 2013, 05:57:06 PM »
It seems to be working pretty good now except for one thing:
if the shape/group is drag-resized it trashes the formula for height and width and replaces them with explicit numbers, so if you later change the number of terminals (through the custom property) the number of terminals change but the size of the overall shape does not!
This occurs even after I put "GUARD" on those formulas!
how can I allow user re-sizing without messing up my height formula?

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: are there similar examples
« Reply #11 on: July 25, 2013, 01:34:05 AM »
There are 2 possible solutions to this:

First, best and more difficult: There's a family of shapesheet functiones the SetAtRef functions. Here is the basic one:
http://msdn.microsoft.com/de-de/library/office/ff765523.aspx
They are difficult to understand, but are usefull in your situation here, but because they are difficult to use, it's to difficult for me to explain. But there were good examples in Graham Wideman's Visio Survival Kid book.

Another solution could be the following:
Make a new user defined cell, User.Control for example, place in there a formula:
=DEPENDSON(Prop.YourCustomPropCell)+SETF(GetRef(Width),"Your formula to calculate the width as String")
or
=DEPENDSON(Prop.YourCustomPropCell)+SETF(GetRef(Width),The calculated value using the formula)

In a similar way you can react to the manual resizing of the shape to allow only discrete values for the width and to change the custom property depending on the width. So the opposite way to the above one.

That could lead to a loop-situation that Visio normaly should be able to resolve. If not: That's why professionals (not me) would use the SETATREF functions.

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #12 on: July 26, 2013, 10:25:42 AM »
Thanks for the info Jumpy.
I'll try those suggestions and see what happens. Do you know of any shapes I can download that demonstrate some of those functions that I could examine?

perry59

  • Full Member
  • ***
  • Posts: 216
Re: are there similar examples
« Reply #13 on: July 30, 2013, 04:11:39 PM »
The shape is resizing as I wish, without the use of SETATREF (which I couldn't get to work right), the only problem is that if the user double clicks it to bring up the custom properties and changes the number of terminals the shape does not shrink or grow to accomodate that. Is there a way I can get the shape to re-calculate its size (which are in user cells) when a custom property changes?
« Last Edit: July 30, 2013, 04:46:06 PM by perry59 »

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: are there similar examples
« Reply #14 on: July 31, 2013, 01:03:31 AM »
What is with a modificated version of the tip above:

=DEPENDSON(Prop.YourCustomPropCell)+SETF(GetRef(Width),The calculated value using the formula)
in a user defined cell.

Dependson fires the SETF-function when the value of the property changes.
SETF sets the cell in GETREF() to the desired value or formula.