Rotate a Shape with Shape Data

Started by DougLittle, July 24, 2019, 01:11:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DougLittle

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

wapperdude

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

#2
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.

wapperdude

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

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

It still isn't working for me, I attached a sample drawing with the part that I'm currently trying to rotate.

Doug

wapperdude

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

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

#8
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.
Visio 2019 Pro

DougLittle

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"):

wapperdude

Where did that CAPCHA appear? 

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

DougLittle

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