Discard *automatic* repositioning of subshapes in a group

Started by Yacine, May 04, 2010, 05:46:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

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.
Yacine

vojo

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

#2
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?
Yacine

vojo

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

#4
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
Yacine

vojo

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

Vojo,
this post was not meant as question, the problem is solved. Check my attachment.  ;)
Yacine

vojo

what attachment...original moves subshapes all over the place

Yacine

 ???
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?
Yacine

wapperdude

Visio 2019 Pro

Visio Guy

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

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

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

@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.
Yacine

Yacine

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.
Yacine