Author Topic: Rotating MLeader text to match UCS  (Read 4290 times)

0 Members and 1 Guest are viewing this topic.

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Rotating MLeader text to match UCS
« on: October 20, 2016, 10:37:24 PM »
I've got a routine inserting mleaders with text.

I want to be able to rotate the text on the mleader to match the UCS.

So far I've tried setting the rotation of the mtext object, .TransformBy, and .SetDogLeg with no results.

Code - C#: [Select]
  1. MLeader label = new MLeader();
  2. MText mText = new MText();
  3. //...
  4. label.MText = mText;
  5. //...
  6. // rotate the mtext to UCS
  7. Vector3d xdir = (Point3d)Application.GetSystemVariable("UCSXDIR") - Point3d.Origin;
  8. double ucsRotation = Vector3d.XAxis.GetAngleTo(xdir, Vector3d.ZAxis);// this seems to be returning the correct angle
  9.  
  10. // none of these work :(
  11. mText.Rotation = ucsRotation; // nope
  12.  
  13. mText.TransformBy(Matrix3d.Rotation(ucsRotation, Vector3d.ZAxis, textPoint));  // nada
  14.  
  15. int idx = label.AddLeaderLine(leaderPoint);
  16. label.SetDogleg(idx,xdir); // nothing
  17.  

What's the best way to accomplish this?


MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Rotating MLeader text to match UCS
« Reply #1 on: October 20, 2016, 11:14:00 PM »
Only guessing here but maybe you need to rotate the MLeader entity not just the MText?
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: Rotating MLeader text to match UCS
« Reply #2 on: October 20, 2016, 11:25:37 PM »
Only guessing here but maybe you need to rotate the MLeader entity not just the MText?

I thought the .SetDogLeg method might do that.

The leader part of the mleader is aligned like I want, I just need the text rotated so it's readable in the rotated view (UCS is set to view)

When done manually, I'm setting the rotation on the text part of the mleader in the properties dialog, so my guess was the the mtext is what needs adjusting. Hence the .Rotation and .Transform methods.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Rotating MLeader text to match UCS
« Reply #3 on: October 20, 2016, 11:30:04 PM »
That makes sense to change it in the properties after creation but on creation, the 'entity' itself (the MLeader) will be placed at the current ucs therefore all it's geometry will be placed at that ucs also, including MText. So, if you set the UCS of the MLeader object as you create it everything it owns should follow.

Another option maybe to set/return the UCS via sysvars in your routine.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

SamR

  • Mosquito
  • Posts: 15
Re: Rotating MLeader text to match UCS
« Reply #4 on: August 28, 2019, 01:53:19 PM »
set label.MText = mText after mText.Rotation = ucsRotation

So
MLeader label = new MLeader()
MText mText = new MText()
mText.Rotation = ucsRotation
label.MText = mText


label.MText.Rotation doesn't work as expected


gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Rotating MLeader text to match UCS
« Reply #5 on: August 28, 2019, 04:54:07 PM »
@SamR, are you SRSDS in the Autodesk forum?
Speaking English as a French Frog

SamR

  • Mosquito
  • Posts: 15
Re: Rotating MLeader text to match UCS
« Reply #6 on: August 30, 2019, 12:44:29 PM »
That's me. I thought I was helping by posting my workaround to this topic.

Gile gave me correct solution on the AutoDesk forum:

Open the Mleader instance
Get the MLeader.MText instance
Set this MText Rotation property as you want
Reset the MLeader.MText to the update MText.

MText yourMText = yourMLeader.MText;
yourMText.Rotation = yourRotation;
yourMLeader.MText = yourMText;


« Last Edit: August 30, 2019, 12:51:46 PM by SamR »