I'm trying to rotate text in an MLeader, but ending up with weird results.
For some/most labels it works, but sometimes the text conflicts with the leaderline. If I double click on the endpoint of the leader, the text corrects it's self to the correct side (wanted.png)
Here's the code I'm using:
private static void SetLabelRotation(IEnumerable<ObjectId> labelIds, LockedTransaction acTr, double rotation)
{
foreach (ObjectId id in labelIds)
{
Entity ent = acTr.GetObject(id, OpenMode.ForWrite, false) as Entity;
MLeader pipeLabel = ent as MLeader;
if (pipeLabel != null)
{
// clone the old text and replace it
MText oldText = pipeLabel.MText;
MText newText = oldText.Clone() as MText;
if (newText != null)
{
// set the rotation
newText.Rotation = rotation;
pipeLabel.MText = newText;
// try resetting attachments? this doesn't work
newText.Attachment = AttachmentPoint.MiddleCenter;
pipeLabel.TextAttachmentType = TextAttachmentType.AttachmentMiddle;
}
}
}
}
I could just recreate the mleader, but I'd really like to keep the same one because I write it's handle to the polyline it's describing. Any ideas?