Visio Guy

Visio Guy Website & General Stuff => Data Visualization & General Graphics Topics => Topic started by: darrenj1471 on October 22, 2014, 10:23:03 AM

Title: Animation (toggle show and hide of connections)
Post by: darrenj1471 on October 22, 2014, 10:23:03 AM
Hi guys

I wonder/hope someone can help, and if what Im after cant be done in visio, perhaps any help how I can.   I have to represent a pretty complex Content Architecture where content objects are authored in one system but published to many systems.

I have a good handle on what I want to produce but not sure on the how.  What Im wanting is a way to only show an objects connections when I select it ie to be able to toggle on or off the connections ideally via hover over but Im getting ahead of myself :) 

Can visio allow toggle on and off (ie hide and show) of connections between objects?  If not do you know any products (ideally freeware) that I can use to create what Im after?  Thanks
Title: Re: Animation (toggle show and hide of connections)
Post by: Paul Herber on October 22, 2014, 10:27:42 AM
Have a look at layers. Assign the connectors to a layer, then turn visibility of the layer on/off.
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on October 22, 2014, 11:47:45 AM
When you say "represent" and "hover", do you mean that you need a fast way to toggle the visibility of the connectors? ie for a presentation?
Then you might consider the event "selection changed".
Title: Re: Animation (toggle show and hide of connections)
Post by: vojo on October 22, 2014, 12:13:03 PM
also...show only the shapes connected to the shape you are hovering over?

I think that would take VBA

I do vaguely recall somebody did some work where the whole sheet is covered in semi transparent.  There was a circle in that that was
complete transparent.....you could move the circle around.   The idea was sort of like show a region of interest.
May not do what you want (connection to shape X that is on the far side the sheet would mean showing the whole drawing).

Some of the people posting here might remember it or have solutions in a similar vein

Might be able to build something yourself (no VBA)
   - 4 rectangles set to 50%
   - 5th rectangle set to 100% transparent and have control points on all 4 sides
   - Each of the 4 would use the appropriate 5th rect contol point to specify width or height
   - Group them all together
   - overlay on drawing of interest

As a result
   - if you move the 5th rectangle (green handles)...other 4 shapes autocalculate
   - if you resize the 5th rect (yellow diamond control points)....other 4 shapes autocalculate
Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 22, 2014, 01:52:18 PM
Another approach would be to use the double click event.  Assign the connectors to a layer per Paul Herber.  Then, open the page shapesheet, set the double click event to toggle the layer visibility.
See attached as example:  http://visguy.com/vgforum/index.php?topic=5740.msg22885#msg22885 (http://visguy.com/vgforum/index.php?topic=5740.msg22885#msg22885)


Per Vojo, the "masking" approach was done by VisioGuy, myself, and Yacine.  Each has slightly different features.  References are as follows:
   VisioGuy:  http://www.visguy.com/2008/11/28/super-mask-visio-clipping-shape/ (http://www.visguy.com/2008/11/28/super-mask-visio-clipping-shape/)
    Wapperdude:  http://visguy.com/vgforum/index.php?topic=494.0 (http://visguy.com/vgforum/index.php?topic=494.0)
    Yacine:  http://visguy.com/vgforum/index.php?topic=5450.msg21608#msg21608 (http://visguy.com/vgforum/index.php?topic=5450.msg21608#msg21608)

Wapperdude
Title: Re: Animation (toggle show and hide of connections)
Post by: darrenj1471 on October 22, 2014, 04:39:42 PM
wow swift replies, thanks Im just digesting them now.

Couple of quick notes:
Yacine, yes I plan to present the diagram and would like it to start with no connections showing and then when 'selecting' an object (be that by clicking it, right clicking it, choosing an option or the hover over was wishful thinking)

Vojo, no I dont want to hide the shapes themselves, they should be visible at all times but the connections themselves are the things I want to hide and show otherwise there will be lots of lines crossing over and be a very busy diagram
I will read your other notes (thanks) but I should say this now, Im clueless at VBA..:)

I will read the rest now and hopefully I'll be able to follow :)

Title: Re: Animation (toggle show and hide of connections)
Post by: darrenj1471 on October 22, 2014, 04:56:33 PM
Ok that example given in http://visguy.com/vgforum/index.php?topic=5740.msg22885#msg22885 is exactly what I want to do

2 questions, how do I add/use layers and how do I assign a double click event to a shape?

This looks exactly what I was after

Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 22, 2014, 06:10:26 PM
Before we go too far, lest I forget, double-clicking a shape to control its visibility, is somewhat problematical.  Hiding it not a big deal, but restoring it can be a problem, like, where is that shape???

That's the reason for the button, it's an independent shape.  The shape could be setup to toggle a specific layer or layers.  Thus you could use multiple buttons if so desired, each for a specific configuration.  Or, use the right click menu and select what to show, not show.

First, assign shape to layer:  just select shape, right click > format > layers.  Create a layer name, and assign the shape to it.  If layer already exists, just select desired layer (or layers).

To change a cell value in the shapesheet from some other cell, use the setf(getref(cellTochange),newValue).  Place the formula in the "controlling" cell. To toggle the value, instead of newValue, use NOT(oldValue), i.e., setf(getref(cellTochange),not(oldValue)).

Since layers belong to the page they're on, the formula looks like:  setf(getref(ThePage!Layers.Visible[1]),NOT(ThePage!Layers.Visible[1])).

To do multiple layers, use the "+" to catenate formulas, e.g., setf(layer[1] formula) + setf(layer[2] formula)


Alternatively, you can use the "actions" right click context menu and select the desired action.

If you open shapesheet of the button, you will see the Action section items.  Same thing as the double click only now, you can pick a specific layer(s) to show hide.  That involves the conditional "IF" formulas which establish the hide/don't hide conditions for each layer.

HTH
Wapperdude
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on October 22, 2014, 09:28:24 PM
Hi Darren,
for your purpose Wapperdudes solution is certainly the best way to go.
Having to entertain an odience necessites to have control over your presentation.
So using a double-click or a selection is better than a hover action, where you might move your mouse inadvertantly and cause disctraction.

Nevertheless, your initial request challenged me to try to get a hover reaction in visio.
I enclose an "essay" of a drawing doing just this. Namely showing connectors connected to a shape over which you hover.
It includes parts of all suggestions made by Paul, Vojo and Wapperdude.
At this late time, I am unfortunately too lazy to try to explain it. May be we can get through the steps on a later time.
Have a try and get an impression of the possibilities of the solution.

The macro is triggered by the "Save" event. So save the document, then move the mouse over the shapes to see it working.
Maybe it can be of use for someone.

Cheers,
Yacine
Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 23, 2014, 01:01:00 AM
@Yacine...

That's just spooky!   :o

Pretty cool!   8)

Wapperdude
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on October 23, 2014, 02:43:47 AM
 8)
Title: Re: Animation (toggle show and hide of connections)
Post by: darrenj1471 on October 23, 2014, 04:58:17 PM
Just about to try the layers instructions but wanted to pick up on the point below.  Perhaps I wasnt clear but I think I said I want to toggle the connections ie the lines.  The shapes should always show.  Ie lets say I have 4 shapes, 2 have a connection to each other and the other 2 have connection to each other.  I dont want both connections showing.  I want to be able to choose which connections to show ie click one object and make its connection show, and like wise on next shape.  Is that clear?  cheers

"Before we go too far, lest I forget, double-clicking a shape to control its visibility, is somewhat problematical.  Hiding it not a big deal, but restoring it can be a problem, like, where is that shape???"
Title: Re: Animation (toggle show and hide of connections)
Post by: darrenj1471 on October 23, 2014, 05:39:47 PM
Err, I mentioned I was a relative newbie right? :)  I fail at first hurdle as you said right click>format>add layer but when I select format I only see Text, Line, Fill and Add Theme?
Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 23, 2014, 06:53:13 PM
@ "Newbie":  not a problem.

The layers thing isn't going to work for what you want.  You will need to run a macro to search for connectors for the shape in question.  Can still use a double click event to trigger the macro.  Should be able to toggle the connectors between show/hide.  Yacine's last effort is a good place to start, with some modifications.  He will probably have an answer before I do. 

The changes would be:
  1.) Replace hover with double click.
  2.) This should avoid the "save" event to trigger.
  3.) Use geometry.noline or geometry.noshow to show/hide the connectors.

Wapperdude
Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 23, 2014, 08:00:28 PM
Attached has a modified version of file I had.  Double click will toggle the connectors.  Need to add the double click "call" to each shape.

Wapperdude
Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 23, 2014, 08:10:04 PM
Added the double click to all shapes...there's a "bug".  The macro "toggles" the connectors period.  That means you cannot progressively go thru and show more and more connectors.  If a shape has connectors showing from some other shape being double clicked, when the next shape is double clicked, it will turn show some connectors and hide those previously connected.

Depends upon what you want to do ultimately.

Wapperdude
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on October 23, 2014, 09:04:50 PM
@Wapperdude,
no, I was not faster than you.
I had to rewrite the whole event handler.
I wish there would be some really generic code snippets, one could easily adjust.
But that's way upon my level.

So this new version features a toggle button to set the drawing in either presentation or edit mode.
There's also the possibility to select several shapes and show accordingly their connections.
Title: Re: Animation (toggle show and hide of connections)
Post by: darrenj1471 on October 24, 2014, 04:00:11 AM
Ok both the hover example and the double click event one are exactly what Im after.   Now......if only I knew how to write macros..

(I will dig out my copy of visio for dummies)
Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 24, 2014, 11:06:10 AM
Couple of things: 
  1.  A somewhat different visual approach...based upon previous work...double click a shape and the macro highlights the shape, plus the attached connectors and shapes at the opposite ends of the connectors.  That is, the complete "network" of the selected shape.  All other shapes are grayed out, but, still lightly visible.  I think this has less "shock" value of all or nothing.  It still allows the viewer to see the context.
  2.  Double click another shape, without the need to double click the first shape, and the emphasis moves to the new shape.
  3.  Repeat double click of same shape will return everything to black lines.

As far as programming goes, the Dummy book probably won't help too much.  Generally, running the macro recorder is a good start.  Also, studying the examples of other macros.  The free download of the SDK has many code examples.

Wapperdude

Ed.:  Cleaned up the code, especially the comments.  Also, added a deselect step to clean-up after macro finishes.
Title: Re: Animation (toggle show and hide of connections)
Post by: darrenj1471 on October 27, 2014, 10:23:04 AM
Ok Ive worked out how to record macros (granted, this wasnt difficult) and I now have some shapes and some macros which if I run they map the connectors between Shape A and B or between C and D for example.  I presume I need to also record a macro where I delete these connectors and this is how I toggle them off?

If I run the same create macro twice it seems to place new connectors on sheet which I dont want....?

What Im now failing to understand is how to assign double click to effect the toggling

Actually there is a fair bit Im failing to grasp so perhaps give me a few days before you end up getting frustrated with my lack of macro skills :)
1. Maps connections between shape A and shape B
2. Removes connections between shape A and shape B
3. Maps connections between shape C and shape D
4. Removes connections between shape C and shape D

Now if run them in order then all is good ie 1 then 2 and then 3 then 4.  I know I cant run 2 before 1 (obviously) as it errors.  BUT if I run 1 and then 3 things goes bad.  The connections from 1 dissapear and a random orphaned connection appears.  Then if I run 1 again after 3 it gets worse ie more orphaned connectors. ....

(Finally, Yacine on your hover up vsd I cannot see any macros so no idea how youve done it)
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on October 27, 2014, 11:28:39 AM
Hi Darren,
there are so many questions in your post, that I don't know where to start.
It is obvious, that you lack the very basics of Visio. (sorry)
What about a generous donation to the forum and we prepare a solution that you can use as it is?
http://www.visguy.com/about/donate/
Title: Re: Animation (toggle show and hide of connections)
Post by: wapperdude on October 27, 2014, 04:27:10 PM
Quote
Ok Ive worked out how to record macros (granted, this wasnt difficult) and I now have some shapes and some macros which if I run they map the connectors between Shape A and B or between C and D for example.  I presume I need to also record a macro where I delete these connectors and this is how I toggle them off?

Not sure why you'd do this.  Thought you already had a drawing and all you wanted to do was manipulate it for viewing/discussion purposes.  To access the macros, hit <alt> F11.  Then, expand modules > NewMacros.  The code should be visible.

First decision you need to make:  use mouse hover or use double-click.  Yacine did the development for this mouse over approach.  He can answer questions relative to that.  I'm happy to cover the double-click approach questions.

If you decide to use double click, there are two approaches presented:  1.) the show / don't show as you requested, or 2.) the highlight alternative approach.  Both of these would require shapesheet editing to be able to invoke the macro with the double click event.  As a starting place, take a look at approach (2), the code is a little cleaner with better comments.  It will help you understand, even if you stick with approach (1).  Open both the Visio drawing window and the VBA window and tile them side-by-side.  Select a shape (single click) in the drawing window, then move the mouse cursor over into the code window.  Press F8 to progressively step thru the code line by line.  As you get into the "action" of the code, you will be able see what each step does and how it impacts your drawing.  Note, after a line of code has executed, you can place the mouse cursor of parts of the line of code to see what their value becomes.

In order to affect the double click behavior, you can right click on a shape and bring up the context window.  Select format > behavior  to get new menu.  Select double-click tab.  Select the Run macro option.  The macro ought to be listed.  (This method is for V2007.  Don't know if it's the same for V2010 or V2013.)  Whatever the process is, you need to do this for each shape to use double-click method.  That's a disadvantage of the double-click approach.  You could also run macro normally thru the Ribbon user interface.

Once you get used to and understand the code (somewhat) then, bring on your questions.  Besides Yacine and myself, there are a lot of regulars who can provide helpful guidance.  Many times, additional eyes spot better ways to do things.

HTH
Wapperdude.
Title: Re: Animation (toggle show and hide of connections)
Post by: novski on November 27, 2014, 02:35:40 AM
Hi Yacine,

It's getting close to Christmas! What does this forum cost for a year?
I may donate something because I'm really interested in such a solution and because i really appreciate your (and all the others) work here...

Hi Darren,
there are so many questions in your post, that I don't know where to start.
It is obvious, that you lack the very basics of Visio. (sorry)
What about a generous donation to the forum and we prepare a solution that you can use as it is?
http://www.visguy.com/about/donate/

Best Regards
Novski
Title: Re: Animation (toggle show and hide of connections)
Post by: Visio Guy on November 27, 2014, 06:31:41 AM
Hi Novski,

The forum is free, and frankly, I don't do much of the work: folks like Paul Herber, JuneTheSecond, Yacine, Vojo, AlEdlund, Wapperdude, Nikolay (sorry for those I've forgotten) answer a TON of questions.

However, I do pay for the webhosting and do all the updating (when Paul H tells me to), so donations are welcome. And I could theoretically buy those guys beer with the proceeds (when they come to Oktoberfest)...which reminds me, I just saw Al in Seattle and didn't buy him a beer!

And you can always send private messages to members asking if they would like to do a bit of custom work on contract if you find yourself over your head or out of time.

Thanks for the generous thought, and good luck finding the information you need!

Chris
Title: Re: Animation (toggle show and hide of connections)
Post by: novski on November 27, 2014, 11:26:09 AM
Is it possible to store Macros in to the shapes? So i can pull it in to my page from the if i need it...?
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on November 28, 2014, 01:43:01 PM
Hi Novski,
no, you can't store macros in shapes.
You can use a stencil that needs to be loaded, or the document itself, but then you need to start from a dedicated template.
The stencil option is better.

Regarding your "package", what are you actually missing?
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on November 28, 2014, 01:44:57 PM
And I could theoretically buy those guys beer ...

I somehow still feel thirsty after all this virtual beer. ;)
Title: Re: Animation (toggle show and hide of connections)
Post by: vojo on November 30, 2014, 09:05:33 PM
If you want to show/hide connections, you can do this

1. take the shape
2. make it a group
3 go into shapesheet and down in the type of select section, there is a cell in middle column top that will show/hide connections
   of children shapes
4.can automate with an action

Something like this....right click the blade

Title: Re: Animation (toggle show and hide of connections)
Post by: Jumpy on December 04, 2014, 12:50:18 PM
And I could theoretically buy those guys beer ...

I somehow still feel thirsty after all this virtual beer. ;)

He Yacine, compared to some of the other guys here your journey to munich would be a short one.  ;D
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on December 04, 2014, 02:08:04 PM
Indeed. We could travel together. I'm sure Chris would not mind buying another beer for you too.


Haven't seen you that often lately in the forum. Busy? May be I could buy you a beer in MG?
Title: Re: Animation (toggle show and hide of connections)
Post by: Jumpy on December 09, 2014, 05:02:05 AM
Indeed. We could travel together. I'm sure Chris would not mind buying another beer for you too.

Haven't seen you that often lately in the forum. Busy? May be I could buy you a beer in MG?

3rd child is arriving soon. In order to take a month of after delivery, I have to finish several projects first and so can't look into the forum that often. Also I had to freeze my evening Visio hobby projects as the wifey is suffering and needs some atttention and backscratching in the evening  ;D
Title: Re: Animation (toggle show and hide of connections)
Post by: Visio Guy on December 09, 2014, 06:41:11 AM
So I guess I won't have visitors for a Christmas Maß at the Hofbräuhaus...?
Title: Re: Animation (toggle show and hide of connections)
Post by: Yacine on December 09, 2014, 01:00:30 PM
Probably not. I look forward for some calm days, no trips, no parties.
Some days off to lick my wounds of the year. ;)