Author Topic: Discard *automatic* repositioning of subshapes in a group  (Read 16108 times)

0 Members and 1 Guest are viewing this topic.

Yacine

  • Hero Member
  • *****
  • Posts: 2923
Discard *automatic* repositioning of subshapes in a group
« on: May 04, 2010, 12:46:59 PM »
Let’s say you have no yet upgraded to Visio 2010 and need to design a container. You would set up a group shape, put in a frame and a label. As behaviour, you’d allow it to accept droped shapes.
So far easy… you add and remove sub-shapes – heaven in Visio World.
Now you will want to extend your group with additional shapes, you widen your group and Uhh… the sub-shapes stretch and move around. No prob, you set their behaviour to „reposition only“. Well that is not enough – the shapes still move in the direction of your stretching. Hmmm… You will open their shapesheets and put numerical values in their PinX, PinY. Fine, they don’t move around anymore when you resize the group.
The very next Monday, you’re asked to update the group and change the position of the sub-shapes, and you notice that the absolute positions are lost. Visio overwrites them with some ParentShape!width*number. Hummm… dumb Visio.
So you go to the obvious – and each time Visio overwrites your Pins - that is every time the eventFXMod is fired - you do the same and overwrite them their same numerical values, without the reference to the parent shape.
eventFXMod=SETF(GetRef(PinX),GetVal(PinX))+SETF(GetRef(PinY),GetVal(PinY))
I found that trivial solution so amazing simple, that I wanted to share it. Enjoy!

PS: The standard behaviour would be that the coordinates refer to the left bottom corner. One will often prefer to extend the group to the bottom, thus refer to the left TOP corner… Just flip your group vertically.

PPS: There are some other features in the attached container. I’ll let you discover by yourselves.
« Last Edit: May 05, 2010, 03:23:28 AM by Yacine »
Yacine

vojo

  • Hero Member
  • *****
  • Posts: 1657
Re: Discard repositioning of subshapes in a group
« Reply #1 on: May 04, 2010, 04:12:54 PM »
Use the guard function

Pinx = Guard(<something like 22mm from left edge>)  kind of thing
or
Pinx = Guard(<14mm from page-1!pinx>) kind of thing

etc

Ie if you make the "container" have a reference point that is fixed....and use that reference point for subshapes...should be able to scale container without affecting subshapes
Localpinx=0 and reference off that.....if move container...shapes move....if you scale container, shapes stay as is..

Visio guy had an article about 6 months ago on how keep a shape center on an x,y when scalling it.   Might be of help

Yacine

  • Hero Member
  • *****
  • Posts: 2923
Re: Discard repositioning of subshapes in a group
« Reply #2 on: May 04, 2010, 04:24:33 PM »
Vojo ...  :-\
How do you want me to move the shapes if I "guard" their positions?

didn't see that article, have you got a title or a link?
« Last Edit: May 04, 2010, 04:32:00 PM by Yacine »
Yacine

vojo

  • Hero Member
  • *****
  • Posts: 1657
Re: Discard repositioning of subshapes in a group
« Reply #3 on: May 05, 2010, 01:30:34 AM »
action.enablemove = setf(getref(actional.enablemove.checked), if(action.enablemove.checked,0,1))

pinx = if(action.enablemove.checked, setatref(user.mypinx),guard(user.mypinx))

something like this should work...may need to play with syntax

In essence, if moves are enabled (right click shape and select enable move), then wherever you move the shape, user.mypinx gets the value....when you turn off moves, the pinx is locked into user.mypinx

This should help

Yacine

  • Hero Member
  • *****
  • Posts: 2923
Re: Discard repositioning of subshapes in a group
« Reply #4 on: May 05, 2010, 02:18:10 AM »
Vojo,
it took me some time to understand you  :-\ sorry. I'm a bit slow.
My title was confusing. It should have stated "Discard *automatic* repositioning of subshapes in a group".

When groups are resized, they will reposition their sub-shapes. That can be quite annoying, when the distance between the sub-shapes matters.
With my suggestion, you can shrink or widen your group and still keep the relative position of the sub-shapes to each other.

Guess this is rather a case for the suggestion box, than for the user-submitted stuff. Visio should offer this additional option as standard. ::)

By the way, I checked your shapesheet - very nice - worth keeping somewhere. :)
... I would probably have rather worked with the protection cells of the shape and/or the group
« Last Edit: May 05, 2010, 12:20:26 PM by Yacine »
Yacine

vojo

  • Hero Member
  • *****
  • Posts: 1657
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #5 on: May 05, 2010, 01:15:58 PM »
I dont think protection would give the choice....I think would be "always moves" or "never moves"

I think you are going to have break out the path to do anything selective
(you may not want to use actions as the trigger....np...but I dont think you can pull this off with only a setatref(xxx,setatrefexpr(setatrefeval))) kind of approach.

Yacine

  • Hero Member
  • *****
  • Posts: 2923
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #6 on: May 05, 2010, 01:19:26 PM »
Vojo,
this post was not meant as question, the problem is solved. Check my attachment.  ;)
« Last Edit: May 05, 2010, 01:21:07 PM by Yacine »
Yacine

vojo

  • Hero Member
  • *****
  • Posts: 1657
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #7 on: May 05, 2010, 01:22:37 PM »
what attachment...original moves subshapes all over the place

Yacine

  • Hero Member
  • *****
  • Posts: 2923
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #8 on: May 05, 2010, 02:04:21 PM »
 ???
I downloaded my own file and it works.
The green valve has the smart behaviour - that is: it stays in place when the group is resized (just to make sure  :D) -, the red one not.
Does it only work on my computer?
« Last Edit: May 05, 2010, 02:08:01 PM by Yacine »
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4331
  • Ideas Visio-lized into solutions
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #9 on: May 05, 2010, 02:23:59 PM »
Container_001.vsd works on V2007.

Visio 2019 Pro

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1734
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #10 on: May 05, 2010, 03:07:34 PM »
This will keep a sub-shape oriented relative to the top-right side of a group:

PinX = SETATREF(User.dx,SETATREFEVAL(SETATREFEXPR(Sheet.3!Width*0.9779)-Sheet.3!Width))+Sheet.3!Width
PinY = SETATREF(User.dy,SETATREFEVAL(SETATREFEXPR(Sheet.3!Height*0.9946)-Sheet.3!Height))+Sheet.3!Height

Sheet.3 is the group
User.dx and User.dy must exist and end up holding the offsets from the right and top sides of the group.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

  • Hero Member
  • *****
  • Posts: 1657
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #11 on: May 05, 2010, 03:33:33 PM »
first and last attach does not work on 2003....scale or move

Ie the green changes position when container scales or moves
(I assume you wanted the green to stay fixed even if the container moved).

I am quite surprised you think those formulas work....in essence, pinx scales with sheet.3!width*0.9779...so if container gets bigger, the pinx of subshapes changes.
(nice trick with width...holds the posiiton in the container constant....though unless move is addressed this is no better than pinx=sheet.3!width*0.9779 kind of thing)
(i.e. alot of heavy lifting to get back to where the basics ;-)  )

Could throw in here a scaling factor similar to the font autoscale...use that to adjust pinx to stay constant as container grows.

I did something similar to this for an "isometric snap" of a shape...but it was always on...not selectively
I have used the scaling approach for isometric shapes alot...though always on


vojo

  • Hero Member
  • *****
  • Posts: 1657
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #12 on: May 05, 2010, 03:37:55 PM »
those equations dont appear in the subshapes....just raw numbers like 95mm.

Must be some sort of dependency on 2007 or later....first time I ever saw that with basics like pinx

Yacine

  • Hero Member
  • *****
  • Posts: 2923
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #13 on: May 05, 2010, 03:46:24 PM »
@Visio Guy
Excuse me Master if I object  ;D,
but I think that I will stay with the flipping option.
The FXMod event method needs only 1 cell to modify, instead of 3 and the user can chose by himself in which direction he wants to stretch the group. The setatref solution would require much more formulas to achieve the same effect.

The whole thing came up because you have absolutely no possibility to resize a complicated group, without changing it's content (positions).
So If the group has the wrong stretching direction, no problem: give the sub-shapes more space, then - in the group window - select the required sub-shapes and reposition them. That is not possible in the standard groups.
« Last Edit: May 05, 2010, 03:56:12 PM by Yacine »
Yacine

Yacine

  • Hero Member
  • *****
  • Posts: 2923
Re: Discard *automatic* repositioning of subshapes in a group
« Reply #14 on: May 05, 2010, 03:52:06 PM »
I just checked that the EventXFMod exists in V2003. It does. Same for SetF and GetRef.
... ???
Will try this at work, where we still use V2003.
« Last Edit: May 05, 2010, 03:54:24 PM by Yacine »
Yacine