[SOLVED] Control Point does not resize properly when changed via Shape Data

Started by nashwaan, October 26, 2011, 08:05:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nashwaan

If we have a simple circle shape with a control point that controls its radius and a Shape Data that shows the current radius of the shape.
Then how to make control point and shape data work together that:

1. if we change position of control point, value of Shape Data 'Radius' should change accordingly
2. if we change value of Shape Data 'Radius', control point should jump to new radius value (but should also maintains same direction with respect to circle origin)
3. if we resize shape, control point should move proportionally




Here is my attempt (see attachment):
Draw a circle shape using Ellipse tool and then do following to its ShapeSheet:

Add a control point row and name it: Controls.Radius

Add a User row and name it: User.Radius
Set formula of User.Radius.Prompt =SETF(GetRef(User.Radius), SQRT( (Controls.Radius.X - Width/2)^2 + (Controls.Radius.Y - Height/2)^2) )

Add a User row and name it: User.Angle
Set formula of User.Angle.Value =ATAN2(Controls.Radius.Y - Height/2, Controls.Radius.X - Width/2)

Set formula of Ellipse geomtery A cell: Geometry1.A1 =Width/2 + User.Radius
Set formula of Ellipse geomtery D cell: Geometry1.D1 =Geometry1.A1

Add a Shape Data row and name it: Prop.Radius
Set formula of Prop.Radius.Value =SETATREF(User.Radius, SETATREFEVAL(SETATREFEXPR()))
                                                      +SETATREF(Controls.Radius.X, SETATREFEVAL(Width/2 + SETATREFEXPR()*COS(User.Angle)),TRUE)
                                                      +SETATREF(Controls.Radius.Y, SETATREFEVAL(Height/2 + SETATREFEXPR()*SIN(User.Angle)),TRUE)


Optional steps (can be skipped):


Make width and height match each other: Height =SETATREF(Width, SETATREFEVAL(SETATREFEXPR()))
Add a Shape Data row and name it: Prop.RadiusPercentage
Set formula of Prop.RadiusPercentage.Format ="0.0\%"
Set formula of Prop.RadiusPercentage.Value =SETATREF(Prop.Radius, SETATREFEVAL(SETATREFEXPR(100)/100*Width/2))*2/Width*100



Everything works except requirement #3 is partially working:  :-\
if we change control point position and then resize shape, the control point moves propotionally to new (correct behaviour).
However, if we change value of radius manually via Shape Data, the control point moves in some weird direction!!!

Any idea how to make control point moves proportionally AFTER manual change to Radius Shape Data? ???
See attached file to check the weired behavior of control point.

Thanks,
Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

wapperdude

Wow!  Not seen anyone use the setatref function so intensively!

My first reaction is that somehow the manual radius change via the table is disturbing the equations.  Something isn't passing correctly.  Soon as you grab the control and move it, then order is restored.  It will take a little more time to sort thru the equations.

Wapperdude
Visio 2019 Pro

wapperdude

OK.  I looked at it a little more closely...

If you open the shapesheet and watch what's going on, there are two very different modes for the controls.radius.  Mode 1 is simply a function of width + an offset.  This mode seems to be when things work correctly.  Mode 2 is after using the shape data to change the width.  Now, the controls.radius has a large equation.  Iif you resize the shape, the equation remains, but the behavior is opposite.  Grab the control and the shape reverts to Mode 1.  My guess, there is a sign inversion somewhere in your equation.

I think all you need to do is swap the sin and cos with each other in your equations.  So, replace sin with cos and visa versa.  I believe that should do it.

HTH
Wapperdude
Visio 2019 Pro

nashwaan

Thanks wapperdude for your reply. Unfortunately swapping the SIN and COS did not solve the problem. In fact, swapping SIN and COS also caused requirement #2 to get disrupted (control point should maintain same direction).
I understand your point that there are two modes, but why two modes are happening in the first place? Shouldn't functions work together in one single loop?

I also noticed this: X Behavior or Y Behavior cell of Controls.Radius affects control point issue. If we change radius manually via Shape Data, the control point will not move correctly during resize (Mode 2 according to wapperdude term). If, before resize, we re-enter 0 in X Behavior (or Y Behavior) cell, the control point will move correctly (even though we are not changing value of X/Y Behaviour). That is, control point will go to mode 1!  ???

Any ideas?  :-\

Thanks,
Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

vojo

This might help....I unpacked it (changed from group first to member first) for you....click until you get a rectangle in top right of shape, that is the connection point loop

Open shapesheet....can see how connection points are created from control points

nashwaan

Hi vojo, I looked into your file but i could not find the part that relates to this problem.

However, i found the answer which turns out to be very silly mistake!

First, i tried to do more examinations on this issue to understand why control point X Behavior and Y Behavior act as if they are set to =2 (Offset from left/bottom edge)... I almost concluded that there was a bug in Visio. In fact, i reached that point and wanted to wirte a post and declare that this is a certain bug. And while i was writing the post, i wanted to prove the bug behvior with one final example... but suddenly, my eyes opened up correctly to notice that, in ShapeSheet, i was writing location of X and Y of control point as value instead of writing them as fraction of Width and Height!  :o

In ShapeSheet formula terms,
instead of incorrect Prop.Radius.Value:
      =SETATREF(User.Radius, SETATREFEVAL(SETATREFEXPR()))
      +SETATREF(Controls.Radius.X, SETATREFEVAL(Width/2 + SETATREFEXPR()*COS(User.Angle)),TRUE)
      +SETATREF(Controls.Radius.Y, SETATREFEVAL(Height/2 + SETATREFEXPR()*SIN(User.Angle)),TRUE)


the correct formula of Prop.Radius.Value:
      =SETATREF(User.Radius, SETATREFEVAL(SETATREFEXPR()))
      +SETATREF(Controls.Radius.X, Width*SETATREFEVAL((Width/2 + SETATREFEXPR()*COS(User.Angle))/Width)), TRUE)
      +SETATREF(Controls.Radius.Y, Height*SETATREFEVAL((Height/2 + SETATREFEXPR()*SIN(User.Angle))/Height), TRUE)


With correct formula, control point will have formulas:
Controls.Radius.X =Width*0.933        [Result = 2.2159 in]   this way, resize will move control point correctly
Controls.Radius.Y =Height*0.75         [Result = 1.7813 in]   this way, resize will move control point correctly

With incorrect formula, control point will have formulas:
Controls.Radius.X =2.2159 in        [Result = 2.2159 in]   this way, control point stays at fixed position
Controls.Radius.Y =1.7813 in        [Result = 1.7813 in]   this way, control point stays at fixed position

By the way, I spent almost a month on this issue :-\. Its a shame to miss a very basic concept of ShapeSheet >:(   But i learned this lesson the hard way. :)

Attached file is the correct behvior (all 3 requirements are fulfilled).

Thanks again wapperdude  8),
Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

vojo

np....BTW, you dont need all that setatref stuff to do this....but if that works for you, congrats