Author Topic: Moving shapes by moving the container, but not individually  (Read 1065 times)

0 Members and 1 Guest are viewing this topic.

Visisthebest

  • Hero Member
  • *****
  • Posts: 863
Moving shapes by moving the container, but not individually
« on: March 26, 2023, 03: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)

Visio 2021 Professional

Yacine

  • Hero Member
  • *****
  • Posts: 3208
Re: Moving shapes by moving the container, but not individually
« Reply #1 on: March 26, 2023, 05:22:01 AM »
Can you elaborate on the purpose, because I would otherwise suggest using groups?
Yacine

Visisthebest

  • Hero Member
  • *****
  • Posts: 863
Re: Moving shapes by moving the container, but not individually
« Reply #2 on: March 26, 2023, 08:23:03 AM »
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.
Visio 2021 Professional

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4837
  • Ideas Visio-lized into solutions
Re: Moving shapes by moving the container, but not individually
« Reply #3 on: March 26, 2023, 11:03:34 AM »
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.
Visio 2019 Pro

Visisthebest

  • Hero Member
  • *****
  • Posts: 863
Re: Moving shapes by moving the container, but not individually
« Reply #4 on: March 26, 2023, 12: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.
Visio 2021 Professional

Surrogate

  • Hero Member
  • *****
  • Posts: 1803
    • ShapeSheet™ Knowledge Base
Re: Moving shapes by moving the container, but not individually
« Reply #5 on: March 26, 2023, 02:13:36 PM »
You can change group shape setting Accept dropped shapes (make this option checked). For shape - Add shapes to groups on drop.

Because of these changes you can do without ungrouping, just move the internal shapes outside the group...
« Last Edit: March 26, 2023, 02:20:49 PM by Surrogate »

Visisthebest

  • Hero Member
  • *****
  • Posts: 863
Re: Moving shapes by moving the container, but not individually
« Reply #6 on: March 27, 2023, 01: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
Visio 2021 Professional

Surrogate

  • Hero Member
  • *****
  • Posts: 1803
    • ShapeSheet™ Knowledge Base
Re: Moving shapes by moving the container, but not individually
« Reply #7 on: March 27, 2023, 02:52:23 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)
« Last Edit: March 27, 2023, 03:14:50 AM by Surrogate »

Visisthebest

  • Hero Member
  • *****
  • Posts: 863
Re: Moving shapes by moving the container, but not individually
« Reply #8 on: March 27, 2023, 03: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.
Visio 2021 Professional

Yacine

  • Hero Member
  • *****
  • Posts: 3208
Re: Moving shapes by moving the container, but not individually
« Reply #9 on: March 27, 2023, 03: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.
Yacine

Visisthebest

  • Hero Member
  • *****
  • Posts: 863
Re: Moving shapes by moving the container, but not individually
« Reply #10 on: March 27, 2023, 05: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).
Visio 2021 Professional