change PinX/Y to absolut Value

Started by axel, October 29, 2013, 08:35:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

axel

Hi

im working a lot with Mobile Network plans.

I often have the problem when I resize a  grooped shape, the position of the included shapes will  also be changed because
Visio saves the PinX / PinY Position as a formula relatet to the grouped shape.
("=Sheet.914!Width*0.5205") -> to the absoulte Value


Is it possible that Visio saves the PinX/Y as an absolut value and not as an formula?

Axel

(VISIO 2003)


vojo

you might be able to try something like this

Pinx = guard(<parent>!width*0.5 + 37.5mm)
Piny = <similar>

If you dont want any artifacts of group scaling....width*0.0+37.5mm

axel

Hi

this is an example of a network plan.

When i try to resize the marked shape, every shape grouped to the shape looses his position and i get a big mess.
The displayed shape is a small one. I have shapes with hundret of grouped shapes which are placed by hand in a way, that there are no crosses and the plan is clear. If i want to resize these shapes, i often get a total mess, because VISIO saves the positions of the Shapes relative to the parent shape. Is there an option that visio stores the position absoulte?


JohnGoldsmith

Hello Axel,

The answer, I think, is no, you cannot tell Visio to use absolute values during resizing unless you've designed this behaviour into the shapes in the first place.  Some questions for you:


       
  • What version and edition of Visio are you using?
  • Did you build these shapes yourself / are you able to change/have control over the masters?
  • Do you want the sub-shapes to always have absolute sizes and positions or just under certain conditions?
  • Why do you want the shapes grouped in the first place?  Does each group represent a single unit that can be moved around the diagram or is it simply a visual frame to indicate some shared location/attributes?
  • Should the user be able to select and or move the sub-shapes?
Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

axel

Hi Jon,

Thank you for your reply


  • Visio 2003
  • No. The plans generated by a planning tool. The user has to order the shapes (like PCB layout)/ Unfortunately not
  • Yes. All sub-shapes sould have absolute position. The size of the shapes is not a problem
  • The marked shape represents a location of a mobile network station. All sub-shapes have to be grouped to this shape because they are in these location.
  • Yes

Best regards

Axel

vojo

num 5 defeats the point you are after

For something like that (move only via actual UI)....you will have to explore the setatexpr statements

or create a manual lock
action.lock = setf(getref(action.lock.checked), if(action.lock.checked, 0, 1))

Pinx = if (action.lock.checked, guard(blah blah), blah blah)

wapperdude

Attached is a sample of what might be done...one possible way.  The key points are:
1.  It is not strictly a grouped shaped.  The "sub-shapes" are "slaved" to the master shape.
2.  The LocPinX and LocPinY of the master shape are each set to "0"
3.  The sub-shapes reference to the PinX and PinY of the master shape plus some offset.
4.  As Vojo indicates, your 5th requirement of user control means that some additional functionality must be added thru the use of setatref function.  Setatref is not fun to work with.

Because this is not a grouped shape, and thus, the sub-shapes are not tied to the master shape's height and width:
1.  Master shape can be moved and subshapes will follow
2.  Master shape can be made wider or taller and subshapes will neither move nor change size.
3.  Because this example does NOT incorporate setatref, once the subshape is manually moved, the formula in its pinx and piny cells will get clobbered.

At best, this is a partial solution.

HTH
Wapperdude
Visio 2019 Pro

vojo

Wapperdude...novel idea to implement a simplified loctoloc....interesting.




AndyW

How about a bit of VBA that runs when you group the shapes or add shapes to the group. Could then go around all the sub-shapes and change the pin positions to absolute values (guarded).
Live life with an open mind

JohnGoldsmith

Hello Axel,

I'm still not really clear whether whether you're looking for a solution without having to modify the shapes or, whether ShapeSheet or code options are available to you?  If it's the former then I think you're out of luck really - there's no way to tell Visio to stop treating group shape resizing (including sub-shape PinX/Y) in a relative manner.

If you're designing the shapes from scratch or want to modify them then one option might be to use the EventXFMod cell to push values into the PinX/Y cells under certain circumstances.  For example, given a Prop.LockShapes Shape Data row in your group shape (ID = 1):

EventXFMod = IF(Sheet.1!Prop.LockShapes,SETF(GetRef(PinY),GetVal(PinY))+SETF(GetRef(PinX),GetVal(PinX)),0)

You then need to deal with the change when Prop.LockShapes value changes and you could do this in two additional User cells:

User.LockStateSyncX = IF(Sheet.1!Prop.LockShapes,SETF(GetRef(PinX),GetVal(PinX)),SETF(GetRef(PinX),"=Sheet."&Sheet.1!ID()&"!Width*"&GetVal(PinX)/Sheet.1!Width))
User.LockStateSyncY = IF(Sheet.1!Prop.LockShapes,SETF(GetRef(PinY),GetVal(PinY)),SETF(GetRef(PinY),"=Sheet."&Sheet.1!ID()&"!Height*"&GetVal(PinY)/Sheet.1!Height))


This would deal with absolute positioning while still allowing the user to sub-select the child shapes and move them as required.  If you also want to lock the size as well, you could set the ResizeMode cell to 1.

Having said all of this it sounds like code might be a better solution in your case as Andy suggests.  Even better, get back to the original design of the shapes so they can be made to perform in the way that you need.

One last point is that I know you said that you're using Visio 2003, but you might want to consider 2010 or above as this introduced the concept of container shapes which looks a lot like what you're trying to achieve.  Containers allow you move a group of shapes as a single unit, resize without changing the size or position of the contained shapes and also allow for programmatic interrogation and reporting.

Hope that helps.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

axel

Hi

QuoteIf it's the former then I think you're out of luck really - there's no way to tell Visio to stop treating group shape resizing (including sub-shape PinX/Y) in a relative manner.

I think this is my problem. As far as i see, there is no simple solution for my problem.

I also thought about VBA, to set PinX/PinY from a formula value to an absolut value, but it's to laborious, because everytime i change the position of a shape after setting to absolute value, Visio changes the PinX/Y to an formula value.

Thanks to everybody.

Axel

wapperdude

One last comment...

If the user doesn't need to reposition the subshapes relative to each other or to the group shape, then, the approach I suggested will work...you just need to put a guard function around PinX and PinY formulas.

I did some setatref investigation, but, was unsuccessful.  Could be me, though.
Visio 2019 Pro

wapperdude

#12
Ohhhh!  So simple after all.  Yes.  Usese setatref function.  See http://msdn.microsoft.com/en-us/library/ms425563.aspx

The methodology:
1.  Not necessary to set the "group" shape's LocPinX and LocPinY to zero, it's just more convenient.
2.  In each subshape, must add the User-defined cells section
     a.  Need two rows
     b.  For convenience rename 1st row to be "Xoff" and 2nd row to be "Yoff" ... without the quotes
     c.  For convenience, set each cell to 0.  This will place the subshape at the PinX and PinY coordinates of the group shape.

3.  Enter following formulas in the PinX and PinY cells.  This is straight out of the above reference.
     a. PinX = SETATREF(User.Xoff,SETATREFEVAL(SETATREFEXPR()-Sheet.3!PinX))+Sheet.3!PinX  where Sheet.3! is the "group" shape ID.
     b. PinY = SETATREF(User.Yoff,SETATREFEVAL(SETATREFEXPR()-Sheet.3!PinY))+Sheet.3!PinY

That's it.  Basically, 1st time through, the PinX and PinY values use the initial values of Xoff and Yoff to position the subshape.  The subshape may be selected and moved to desired location.  The setatref formula takes this new location and shoves it into the User.Xoff and User.Yoff cells.  These then feedback into PinX and PinY cells.  By making the group shape's LocPinX,Y entries 0, the offsets are always positive numbers.  But, as indicated, that's merely a convenience.

It would also be possible to use the ShapeData section instead of the User-cell section.  Then the formulas would contain Prop.Xoff and Prop.Yoff.  This allows the added flexibility of letting the user to enter specific offsets via menu.

The attached Visio file has this updated approach.


HTH
Wapperdude
Visio 2019 Pro

wapperdude

#13
One final note.  The shapes may be grouped normally.  However, it does slave the subshapes width and height to the parent shape.  So, it may be desireable to use the guard function.

The top group shape obviously is the reference shape for each of the subshapes.
Visio 2019 Pro

Yacine

Yacine