Visio Guy

Visio Discussions => General Visio => Topic started by: miless2111s on August 31, 2016, 03:16:31 PM

Title: glueing two shapes to each other - glue control handle
Post by: miless2111s on August 31, 2016, 03:16:31 PM
I would like to be able to glue two shapes to each other (shape A attached to shape B) so that when shape B moves shape A is dragged around maintaining their relative position.

I can do this if I use the shapes in the Brainstorm / Legends set however it would be nice to have the whole range of shapes available.

When using the Brainstorm Legends I select the yellow (visio 2010) handle at the bottom left of shape A and drag it onto shape B.  Job done.

I can make the yellow handle appear in any shape (open the shape sheet and ask to see the control section) however this doesn't replicate the functionality of the legend shape :(

What am I missing?

Many thanks

Miles
Title: Re: glueing two shapes to each other - glue control handle
Post by: Yacine on August 31, 2016, 09:18:39 PM
Haven't found the shapes you're talking about. Can you upload a file?
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on August 31, 2016, 10:28:08 PM
How do I upload a file?
The shapes I refer to are under business / brainstorming legends
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on August 31, 2016, 10:32:39 PM
When making a post, underneath the text entry area is Attachments and other options.  Expand that.  Click the browse button.  You can then navigate on your computer, find the file, and add it.

That it.

Wapperdude
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 01, 2016, 07:22:12 AM
Thanks Wapperdude, the test file should be attached here...
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 01, 2016, 08:41:51 AM
OK, an update which may or may not help....

I have copied a bunch of User Defined cells in the shape sheet of the Important (!) shape from the brainstorm legends set into the rectangle:
visConNameX
visConNameY
visConPt
visDeltaX
visDeltaY
visLocToPar

And copied the following formula into the PinX and PinY cells:
PinX =PNTX(LOCTOPAR(User.visConPt,ThePage!PageWidth,Width))+User.visDeltaX
PinY =PNTY(LOCTOPAR(User.visConPt,ThePage!PageWidth,Width))+User.visDeltaY

And now it works as long as I don't move the Glued box.  If I do that the PinX and PinY values revert to normal dimensional (x mm) values as the VisDeltaX and VisDeltaY values don't change.

When I move the Important ! shape around relative to the target rectangle the DeltaX and DeltaY values change and the PinX and PinY entries remain formulas and everything works as it should.

When I look into the cells for VisDeltaX and Y they are just values (=0.5708) but it seems that they're getting a value from somewhere.  Are they build in custom items with hidden formula or something else?  When I copy the =0.5708 from the Important shape to the rectangle shape they're coming across as dumb numbers and not changing when the rectangle is moved around.

Any ideas gratefully received! :)

Thanks

Miles
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 01, 2016, 03:05:00 PM
Looked at your 1st uploaded file.  The issue is the nature of the connection points.  Visio has 3 types:  Inward, Outward, and "Inny/Outty".  Select a shape, e.g., the "glue to shape", the select the Connection Point tool.  Hover tool over the connection point on the right side and right click.  A pop-up will appear showing the 3 connection point options.  Choose either Outward or the Inward/Outward.  Now, drag the shape to the target shape, overlapping the connection points.  The connection point should turn red indicating it's glued.  Now select target shape and move it.  It will drag the other shape around.

Wapperdude
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 02, 2016, 07:00:55 AM
OK, Wapperdude, that worked to join them together in a close coupled way however as soon as I move the "glue to" away from the "target" shape that link is broken.  This is different to the behaviour of the Important shape where the link remains and the "glue to" moves around with the "target" maintaining the same special relationship set by moving the "glue to" relative to the "target".

Can we make normal shapes replicate this joined-at-a-distance behaviour?

Thanks
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 02, 2016, 02:29:16 PM
Yes.  A bit more work, but not difficult.  What is needed is a control point in each shape, i.e., the yellow handle.  You must edit each shape.  Once you make a change, this is local to this drawing only.  In fact, it is to that shape only.  So, at a minimum, you should edit the local "master" on the document stencil, not on the page.  That way, all shapes in the doc that use the master will be updated.  To  make this more universally available, you will need to save a copy of the shape to a custom  stencil.  Then, that stencil will be available when chosen and you can drag and drop from it.

The process would be to select a shape and open its shapesheet.  Mouse over the  shapesheet, right click, then choose insert section  and select the control entry.  I believe the default default entry for x, y location is width*0, height*0.  I like to nudge these off a little, to the outside of  shape, so maybe each entry gets -0.05.  This value will change soon as you move the control.  Lastly, at the end the control row, make sure it says can glue.  That's it.

HTH
Wapperdude
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 02, 2016, 04:34:25 PM
Wapperdude, I'll check after dinner but from memory that's what I have been doing and it didn't work :( maybe I was missing something stupidly simple.?
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 02, 2016, 04:47:12 PM
Hmmm...

Possibly under snap / glue options, glue to shape geometry isn't selected?
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 05, 2016, 07:48:29 AM
Wapperdude

Sorry for the delay in responding - the weekend got a bit busy!

I have confirmed that your "add a control line to the shape sheet" is what I have been doing and this doesn't replicate the same functionality as the "important" shape :(  I can display a control and drag it onto the target shape and the end goes red.  However it doesn't appear to DO anything - when either shape moves nothing special happens in that the red dot stays stuck to the target but nothing happens to either shape :)

I also watched the shape sheet for the "important" shape and when it is dragged onto the page it is fairly normal however as soon as you drag the control handle to the target shape and glue it a whole load (below) custom user lines appear in the shape sheet!
visConNameX
visConNameY
visConPt
visDeltaX
visDeltaY
visLocToPar

Given that the "important" shape behaves as required when the new shapes don't I fear it isn't anything that is set at the page level...
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 05, 2016, 02:36:47 PM
Can you upload a Visio drawing that has two shapes...one that you modified plus the one to which you want the control handle to be glued.

Save as vise, please.

Thanks.

Wapperdude
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 05, 2016, 03:04:19 PM
Quote from: wapperdude on September 05, 2016, 02:36:47 PM
Can you upload a Visio drawing that has two shapes...one that you modified plus the one to which you want the control handle to be glued.

Save as vise, please.

Thanks.

Wapperdude
I've attached the .vsd (I don't know what the VISE is - if this is incorrect can you tell me how to save as VISE?
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 05, 2016, 03:53:39 PM
Vise... :o ??? :P ::)...did that from tablet...forgot to check auto correct.

Vsd is perfect...Will take a look.
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 05, 2016, 05:56:42 PM
Sorry, I must retract my assessment of adding the control point behavior.  It is not nearly so easy.  There is some built-in, underlying code that makes the PinX and PinY track with the control point once it is attached to another shape.  That code is inaccessible.

I considered the possibility of modifing an existing "Important" shape to retain all of the behavior, plus add the functionality of the "Callout" shape.  However, the Callout also utilizes built-in code it is no longer a trivial exercise to add its behavior to the modified Important shape.  The easiest work-around might be to group the two shapes, temporarily, move them, then ungroup.

Again, my apology.

Wapperdude.
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 05, 2016, 06:01:38 PM
No worries, I'm glad I'm not alone in this and it wasn't something I was missing :)
Shame though - it would have been fantastically powerful to have the ability to hard link shapes for annotations etc.
Thanks for trying :)
Regards
Miles
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 05, 2016, 06:45:02 PM
I don't like disappointing.   >:(

Attached should work.  I did rework an "Important" shape.  Think I captured most of the desired behaviors.  Plus, added 1...the height of the vertical line will be the larger or the two cases:  text height or drawn height.  It will grow automatically, but, will not shrink unless manually resized.

To distinguish the new shape, I had to rename it from Important.  It still thinks it's master is Important, pun and no pun intended!   :o   That way it still gets the built-in effects.

Wapperdude
Title: Re: glueing two shapes to each other - glue control handle
Post by: Nikolay on September 05, 2016, 08:01:00 PM
Brainstorm legend shapes appear to be managed by Visio "brainstorm" addin (solution), not by Visio core. That essentially means that all those user cells are created by background "brainstorm" addin which is obviously limited to brainstorm diagram type, so I would avoid messing with those :)

For a similar general-purpose solution, you could probably just use "callout" shapes (Insert => Callout). Read more about callouts here for example:
https://support.office.com/en-us/article/Annotate-a-diagram-by-using-callouts-2f3a8780-4bab-45a3-88dc-ad2ac0b79cb9
https://blogs.office.com/2012/11/05/containers-and-callouts-in-visio/

There are various stock callouts that may fit you needs. You can build you own custom callouts, if you want to. See here for example:
https://blogs.msdn.microsoft.com/visio/2010/01/12/custom-containers-lists-and-callouts-in-visio-2010/
https://blog.bvisual.net/2014/04/08/adding-configure-callout-functionality-to-visio-callouts/
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 05, 2016, 11:01:54 PM
Ah.  Yes.  I see where my "solution" might be misleading... wasn't really clear about the underlying code, nor the fact that the code is tied to the brainstorm addin, thus leaving open the possibility of "transporting" the solution to other Visio applications.

Guess it's one of those weekends.

Well, for a very limited scenario, the "solution" does work.

Thanks Nikolay.
Wapperdude
Title: Re: glueing two shapes to each other - glue control handle
Post by: miless2111s on September 06, 2016, 01:35:12 PM
Quote from: wapperdude on September 05, 2016, 06:45:02 PM
I don't like disappointing.   >:(

Attached should work.  I did rework an "Important" shape.  Think I captured most of the desired behaviors.  Plus, added 1...the height of the vertical line will be the larger or the two cases:  text height or drawn height.  It will grow automatically, but, will not shrink unless manually resized.

To distinguish the new shape, I had to rename it from Important.  It still thinks it's master is Important, pun and no pun intended!   :o   That way it still gets the built-in effects.

Wapperdude
It's interesting - the behaviours of these shapes are inconsistent; initially when opened moving the target shape around moves the linked items as required, however as soon as they are repositioned they start behaving like normal call outs - i.e. they're fixed in place and the line moves to maintain the link with Target. :(
Another interesting feature is that when you grab the horizontal arrow cursor that appears in the centre of the call out text line and drag it right over the text the line extends from top to bottom of 6 pages up and down!
Sorry that your work didn't manage to achieve what we wanted - I'll use your earlier suggestion of a rectangle hard glued to a brainstorm shape if I want to associate text with the "important" symbol.
Regards
Miles
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 06, 2016, 02:15:09 PM
Odd that it misbehaves.  The only significant change, I would think, was re-naming the shape, but keeping the master shape reference.  While I didn't try it in a busy environment, I did copy/paste, drag/move many more times  appears in the attached file.  Would have thought any fundamental issues would  surfaced.  All other changes were superficial. 

Oh well.

Wapperdude
Title: Re: glueing two shapes to each other - glue control handle
Post by: Yacine on September 06, 2016, 03:42:11 PM
Wouldn't Wapperdude's magic setatgetref things be a typical solution for this problem?
I recall him solving such a problem for me a while ago. http://visguy.com/vgforum/index.php?topic=5450.0;nowap
Title: Re: glueing two shapes to each other - glue control handle
Post by: wapperdude on September 06, 2016, 09:06:58 PM
Don't think so...at least, not in this case.  The problem is the limited functions avaliable in the shapesheet.  There's no way to test for gluing and there's no way to parse a formula.  Consequently, there's no way to determine if the control point is glued to something or not.  If there was, then, yes, I think the SetAtRef stuff ought to work.

Perhaps the newer versions of Visio have added shapesheet functions...but, that's for someone else to tackle.

Wapperdude