Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: DougLittle on July 24, 2019, 01:11:31 PM

Title: Rotate a Shape with Shape Data
Post by: DougLittle on July 24, 2019, 01:11:31 PM
I have become a huge fan of this forum over the last few months, since I started a new job working with Visio almost every day. I have been able to solve most of the problems I've had, and few that someone else had, just by reading the old posts. Now I've got a problem that I can't quite find an answer for, although a few come close. I'm trying to rotate a grouped shape in 90 degree increments based on a shape data field. I created the ORIENTATION field in shape data, and made it a fixed list with "UP;LEFT;DOWN;RIGHT" in it's Format. I created user.ORIENTATION with the formula INDEX(LOOKUP(Prop.ORIENTATION,Prop.ORIENTATION.Format),0 deg,90 deg,180 deg,-90 deg), which should match the index of the current selection in prop.ORIENTATION.Format to the proper orientation, but it's not working. Up = 0 degrees, as it should, but all other orientations = 180 degrees.

Doug
Title: Re: Rotate a Shape with Shape Data
Post by: wapperdude on July 24, 2019, 03:03:14 PM
Few things:
1)  You don't mention this, but I assume that the group angle value is pointing to user.ORIENTATION.

2)  With your construction, youi don't need the "LookUp" fcn.  Your formula needs only be INDEX function.

3)  Your formula has syntax error.

So, fixing (2) & (3):  =INDEX(Prop.Orientation,"0 deg;90 deg;180 deg;-90 deg")

Prop.Orient remains fixed list, but your format becomes:  0;1;2;3 as the 1st index value is "0" not "1".
Title: Re: Rotate a Shape with Shape Data
Post by: DougLittle on July 24, 2019, 03:15:31 PM
Thank you for taking a look at it, unfortunately it still isn't working. I am using a SETATREF in the Angle cell to match user.ORIENTATION, but that is working fine so I didn't menton it. With your code, user.ORIENTION has a value of #VALUE, so the angle doesn't change regardless of what I put in the shape data. Using Visio 2016 Pro on Windows 10.

Doug

p.s. Please leave political commentary out of the CAPCHA.
Title: Re: Rotate a Shape with Shape Data
Post by: wapperdude on July 24, 2019, 05:00:46 PM
The setatref info was important because it affects the same cell, Angle, as does the Prop.Orientation, ultimately.

It's possible to do both.  See attached.  Basically, remove the formula from the Angle cell and    move the SETATREF formula into the Prop.Orientation.value cell.  Have the formula point to the Angle cell.  The angle cell will accept GUI normal GUI inputs, and the value pushes back to the Prop.Orientation.  Because of this push back, you must add a new entry at the start of the Index formula.  In my example, I call it "angle".  This works around an issue with the push back and the Indexing.  Basically, it's a dummy placeholder.

The user.ORIENTATION cell is not needed.
Title: Re: Rotate a Shape with Shape Data
Post by: vojo on July 24, 2019, 05:28:07 PM
probably want to throw in GUARD into the formula in the angle cell
GUARD would protect that cell from the user rotating thru the UI.

Also you could use SETF

Angle = 30 deg
Prop. orient = 45 deg
Actions.orent = setf(getref(Actions.orient.checked), if(actions.orient.checked, 0,1))
User.orient = if(actions.orient.checked, setf(getref (angle), prop.orient),)

Right click shape ==>select actions.orient

Angle now is 45 deg

This would allow you reassign angle to prop.orient value after a user messed it up by rotating thru UI

Finally you could look at protections to prevent user for messing shape up....right click shape ==>protections==>rotation
Title: Re: Rotate a Shape with Shape Data
Post by: DougLittle on July 24, 2019, 06:28:16 PM
It still isn't working for me, I attached a sample drawing with the part that I'm currently trying to rotate.

Doug
Title: Re: Rotate a Shape with Shape Data
Post by: wapperdude on July 24, 2019, 09:54:54 PM
All is well.  Fortunately, you supplied a sample.  Otherwise, this might have taken a very long time.

A major issue was that the shape was set to 1-D behavior, not 2-D.  There is no angular behavior with 1-D shapes per se.

Went thru the formulas.  Some tweaking.  User.ORIENTATION is just a placeholder, no embeded formulas.  Both Prop.ORIENTATION and Angle have the necessary formulas.  Kept your Up, down, left, right approach.  Had to add the placeholder in the Index definitions.


Title: Re: Rotate a Shape with Shape Data
Post by: DougLittle on July 25, 2019, 12:14:48 PM
I'm glad you were able to find the solution, I had previously changed the part from 1d to 2d, but I guess that got lost in reverting other changes. Unfortunately, you attached an empty file as the solution.

Doug
Title: Re: Rotate a Shape with Shape Data
Post by: wapperdude on July 25, 2019, 03:23:24 PM
There's something weird going on with your file.  Besides coming up blank, it won't retain the 2-D setting.  So I've copied the part to a new blank file.
Title: Re: Rotate a Shape with Shape Data
Post by: DougLittle on July 25, 2019, 05:58:42 PM
Thank you, other than it listing the orientation as default regardless of actual orientation, it works perfectly.

Doug

p.s. This is what I was referring to about political commentary in the CAPCHA:
QuotePresident of the United States: Donald J. _____ (the "J" stands for "Joke"):
Title: Re: Rotate a Shape with Shape Data
Post by: wapperdude on July 25, 2019, 09:14:11 PM
Where did that CAPCHA appear? 

...and you're right, it's an unnecessary commentary.
Title: Re: Rotate a Shape with Shape Data
Post by: DougLittle on July 26, 2019, 12:10:36 PM
It's part of the CAPCHA when I post, I've seen that particular message twice. Obviously somebody at simple machines forum thinks they're clever.

Doug