### Author Topic: Rotate a Shape with Shape Data  (Read 1049 times)

0 Members and 1 Guest are viewing this topic.

#### DougLittle

• Newbie
• Posts: 6
##### Rotate a Shape with Shape Data
« on: July 24, 2019, 08:11:31 AM »
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
Code
``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

#### wapperdude

• Global Moderator
• Hero Member
• Posts: 3821
• Ideas Visio-lized into solutions
##### Re: Rotate a Shape with Shape Data
« Reply #1 on: July 24, 2019, 10:03:14 AM »
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".
Visio 2019 Pro

#### DougLittle

• Newbie
• Posts: 6
##### Re: Rotate a Shape with Shape Data
« Reply #2 on: July 24, 2019, 10:15:31 AM »
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.
« Last Edit: July 24, 2019, 10:22:17 AM by DougLittle »

#### wapperdude

• Global Moderator
• Hero Member
• Posts: 3821
• Ideas Visio-lized into solutions
##### Re: Rotate a Shape with Shape Data
« Reply #3 on: July 24, 2019, 12: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.
Visio 2019 Pro

#### vojo

• Hero Member
• Posts: 1513
##### Re: Rotate a Shape with Shape Data
« Reply #4 on: July 24, 2019, 12: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

#### DougLittle

• Newbie
• Posts: 6
##### Re: Rotate a Shape with Shape Data
« Reply #5 on: July 24, 2019, 01: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

#### wapperdude

• Global Moderator
• Hero Member
• Posts: 3821
• Ideas Visio-lized into solutions
##### Re: Rotate a Shape with Shape Data
« Reply #6 on: July 24, 2019, 04: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.

Visio 2019 Pro

#### DougLittle

• Newbie
• Posts: 6
##### Re: Rotate a Shape with Shape Data
« Reply #7 on: July 25, 2019, 07:14:48 AM »
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

#### wapperdude

• Global Moderator
• Hero Member
• Posts: 3821
• Ideas Visio-lized into solutions
##### Re: Rotate a Shape with Shape Data
« Reply #8 on: July 25, 2019, 10:23:24 AM »
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.
« Last Edit: July 25, 2019, 11:21:54 AM by wapperdude »
Visio 2019 Pro

#### DougLittle

• Newbie
• Posts: 6
##### Re: Rotate a Shape with Shape Data
« Reply #9 on: July 25, 2019, 12: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:
Quote
President of the United States: Donald J. _____ (the "J" stands for "Joke"):

#### wapperdude

• Global Moderator
• Hero Member
• Posts: 3821
• Ideas Visio-lized into solutions
##### Re: Rotate a Shape with Shape Data
« Reply #10 on: July 25, 2019, 04:14:11 PM »
Where did that CAPCHA appear?

...and you're right, it's an unnecessary commentary.
Visio 2019 Pro

#### DougLittle

• Newbie
• Posts: 6
##### Re: Rotate a Shape with Shape Data
« Reply #11 on: July 26, 2019, 07:10:36 AM »
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