SetRotation() strange behavior with clockwise rotations

259
4
02-04-2020 11:52 AM
DavidLaMartina
New Contributor III

I am trying to programatically rotate a piece of text of a Layout. The Element class's SetRotation() method works as expected with positive numbers (counterclockwise rotations), but trying to use negative numbers for clockwise rotations is not. Instead of simply rotating in the expected rotation, the piece of text is rotated and turned upside down.

The result looks like this:

If I want to rotate up to 90 degrees to the left / counterclockwise, things turn out okay. But if I need to rotate the opposite way, such as in this scenario, the text ends up flipped so that you'd have to skew your head more than 90 degrees to see it straight.

Is there some extra anchor setting I need to use to get the expected behavior? Using the Arc Pro GUI, inserting a Layout element and setting the rotation does not cause the same behavior.

0 Kudos
4 Replies
UmaHarano
Esri Regular Contributor

Hi David

Can you please share a code snippet? I am not seeing this behavior with 2.4 so a code snippet might help to narrow down what you are seeing.

Thank you!

Uma

0 Kudos
BrianBulla
Regular Contributor

Hi Uma Harano‌.  Do you know if this is still an issue?

I am trying to do something similar.....rotate a point feature symbol (ie. set ROTATION field) to a value that orients it properly for mapping.  In my old ArcObjects code I would do this with "line" being the line that the point is attached to at the TO node.

object missing = Type.Missing;
ILine line = new LineClass();
line.FromPoint = fromPoint;
line.ToPoint = toPoint;

double angle = (180 * line.Angle / (System.Math.PI));

return angle;

In ArcPro SDK I have tried everything I can think of to get this to work, but the results are all over the place.  I have no idea where I am going wrong.  i am creating the line in ArcPro SDK like this:  

var lineBuilder = new LineBuilder(fromPoint, toPoint);
var line = lineBuilder.ToSegment();

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Brian,

Is this the workflow you are trying to achieve?

1. Create a line (Is this a graphic line element in a map/layout?)

2. Get the inclination angle of the line.

3. Align text on this line.

Thanks

Uma

0 Kudos
BrianBulla
Regular Contributor

Hi Uma Harano‌,

I eventually figured this out.  Back in ArcObjects, things just seemed to work differently.  What I am trying to do is set the ROTATION of an 'end of line' point feature so that things look proper when mapping.  After lots of messing about, I finally figured out that if I just applied a * -1 to my formula and then everything worked.  

var lineBuilder = new LineBuilder(fromPoint, toPoint);
var line = lineBuilder.ToSegment();

double Rad2Degrees = 180 / Math.PI;
var degrees = (line.Angle * Rad2Degrees) * -1;
return degrees;

Thanks for getting back to me.

0 Kudos