Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: Visisthebest on March 26, 2023, 08:31:49 AM

Title: Moving shapes by moving the container, but not individually
Post by: Visisthebest on March 26, 2023, 08:31:49 AM
I have a specific challenge with achieving the following, is it possible with shapesheet formulas to get shapes to move only when the container they are in is moved, but not when the user tries to move the shapes individually?

(Ideally a solution where with VBA it is still possible to change PinX and PinY on the shape, but this is not a requirement as I can solve it in code anyway by temporarily removing the formula, then changing PinX/PinY on the shapes, and put the formula back)

Title: Re: Moving shapes by moving the container, but not individually
Post by: Yacine on March 26, 2023, 10:22:01 AM
Can you elaborate on the purpose, because I would otherwise suggest using groups?
Title: Re: Moving shapes by moving the container, but not individually
Post by: Visisthebest on March 26, 2023, 01:23:03 PM
The custom flowchart shapes (each a group shape) in the container are typically about 2 to 12 shapes (per container) that make up a logic unit in the flowchart (which runs from left to right, hence containers work well for this. The container heading is the name for this logic unit, the user should not be able to change these shapes and move them around in the container they are a standard that cannot be changed. Shapes are also protected against deletion for instance.
Title: Re: Moving shapes by moving the container, but not individually
Post by: wapperdude on March 26, 2023, 04:03:34 PM
Everything you describe can be done with a group, no code, except for cases you want to deliberately change.

The advantage of containers is the underlying code which allows you to see membership, placement ordering, growing in size as members are added/changed.  Said code also moves members with the container.  But, unlike a group, the members Pins X and Y refer to page location rather than parent location.  It's built-in.  It would, indeed, take code to lock the relative positions.  Conclusion:  for your specifications, stick with group.
Title: Re: Moving shapes by moving the container, but not individually
Post by: Visisthebest on March 26, 2023, 05:23:00 PM
Thank you Wapperdude, I thought of Containers because I want users to create 'standard parts' of a workflow and for them it is easier to arrange shapes in a container than to use grouping/ungrouping (users often don't understand that they can cause issues especially when ungrouping), but yes for how I want it to work a group is more suitable.

Another aspect, I haven't used group shapes in group shapes before, worried that this may cause performance or other issues, but maybe unnecessarily worried about this.
Title: Re: Moving shapes by moving the container, but not individually
Post by: Surrogate on March 26, 2023, 07:13:36 PM
You can change group shape setting Accept dropped shapes (make this option checked). For shape - Add shapes to groups on drop.
(https://bvisual.net/wp-content/uploads/2016/06/image7.png)
Because of these changes you can do without ungrouping, just move the internal shapes outside the group...
Title: Re: Moving shapes by moving the container, but not individually
Post by: Visisthebest on March 27, 2023, 06:19:42 AM
Thank you Surrogate! That does make it easier for end users to create a group shape by just dropping in shapes in to the group :D
Title: Re: Moving shapes by moving the container, but not individually
Post by: Surrogate on March 27, 2023, 07:52:23 AM
Quote from: Visisthebest on March 27, 2023, 06:19:42 AM
That does make it easier for end users to create a group shape by just dropping in shapes in to the group
Yes, it's even easier to use the hotkeys
For shape (receiver): Ctrl+G (make group), Alt+L+B+D (Accept dropped shapes).
For other shapes: Alt+L+B+H (Add shapes to groups on drop).
Or even write macro or add-in for automate these actions  8)
(https://user-images.githubusercontent.com/35092915/227880829-388358b4-f496-4299-93f1-eead359ec10b.gif)
Title: Re: Moving shapes by moving the container, but not individually
Post by: Visisthebest on March 27, 2023, 08:27:21 AM
Thank you Surrogate handy to know for myself but I will probably write a macro for this for end users, they often have difficulty with hotkeys where they have to press more than 2 keys.
Title: Re: Moving shapes by moving the container, but not individually
Post by: Yacine on March 27, 2023, 08:55:11 AM
Not really. You are preparing a stencil anyway. So set the drop properties before hands for the group and the sub-shapes. Your users don't need to worry about them at all.


The macro would only be useful if you want to allow the users to add freely created new shapes.
Title: Re: Moving shapes by moving the container, but not individually
Post by: Visisthebest on March 27, 2023, 10:20:40 AM
For the group shape (the 'fake' container) you're right Yacine, but will allow users to user their own workflow shapes, so for these it is nice a bit of code can configure them properly for the user (I am adding some user fields in code already, so might as well set the shape to be droppable in to a group).