Constrain Control Points to Rectangle Perimeter

Started by spandex, July 03, 2014, 12:29:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

spandex

I am trying to define a rectangular shape with multiple control points. I'd like to constrain the movement of each control point to the perimeter of the square. I have tried various combinations of SetAtRef, SetAtRefEval, and SetAtRefExpr, but I haven't had any success. Any pointers would be greatly appreciated.

AndyW

You just need to use BOUND(Width*0.5,0,FALSE,0,Width) for X on the control point and similarly for Y, BOUND(Height*0.5,0,FALSE,0,Height)
Live life with an open mind

spandex

But won't that allow the control point anywhere inside the rectangle (instead of constraining it to the perimeter)?

JuneTheSecond

#3
I think BOUND function is a right way to a solution.
GARD function, EVALCELL function and ARG function may be useful.
I have 2 simple example shapes as is in my attached drawing.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

wapperdude

#4
With respect to your rectangular shape, you can use the Bound function with conditional IF statements nested inside.  The approach below uses the X direction to control the Y-position.

If X is at either 0 or full width, it sets the bound Y limits as min = height*0 and max = height*1.  This allows vertical travel.  If X position is in between the two extremes, then the min and max Y values, are identical and can be either height*0 or height*1 and only allows horizontal travel.

The Bound formula for the Y Cell has the format:  Bound(current pos,0,false,Lim1,Lim2,false,Lim3,Lim4).  The Lim1,Lim2 values are controlled by the nested IF statements and cover 3 of the 4 possible conditions.  Lim3 and Lim4 provide the necessary final 4th condition.  The Bound fcn operates such that based on the current position, it will either apply the Lim1&Lim2 limits or else the Lim3&Lim4 limits.

The nested IF statements work like this:  if case1 is true, use 1st value, otherwise, use 2nd IF statement.  If 2nd statement is true, use the next value, otherwise, use the 3rd value since both IF's are not true.

For the control point cell formulas are as follows:

X Cell: Bound(width*0,0,False,width*0,width*1)        (Note:  Visio will automatically fill in the 1st value and it doesn't have to be entered.)

Y Cell:  =BOUND(Height*0,0,FALSE,IF(OR(Controls.R1=Width*1,Controls.R1=width*0),Height*0,Height*0),IF(OR(Controls.R1=Width*1,Controls.R1=width*0),Height*1,Height*0),FALSE,Height*1,Height*1)

Note:  I renamed the control row to be Controls.R1

This allows the control point to follow the perimeter of the rectangle. 

HTH

Visio 2019 Pro

spandex

Thank you all so much for your help. I need to take some time to thoroughly understand the solutions.