How to modify the defined height of MText through COM API in C#?

How to modify the defined height of MText through COM API in C#?

1605027848
Participant Participant
1,718 Views
6 Replies
Message 1 of 7

How to modify the defined height of MText through COM API in C#?

1605027848
Participant
Participant

I use command:

AcadApplication AppAutoCAD = new AcadApplication();
AcadDocument AcDocument = AppAutoCAD.ActiveDocument;
AcadModelSpace AcModelSpace = AcDocument.ModelSpace;
AcadMText AcMText = AcModelSpace.AddMText(new double[] { 0, 0, 0 }, 0, "你好");
AcMText.Width = 50;
AcMText.Height = 30;

The result is the width of MText changed. Also the height of MText changed, but it changed the text height, not defined height. So, how to change the defined height?

0 Likes
Accepted solutions (1)
1,719 Views
6 Replies
Replies (6)
Message 2 of 7

seabrahenrique
Advocate
Advocate

Hello!

 

I gues THIS FORUM is more appropriate to this problem in C#.NET 

 

Hope can help u 🙂

0 Likes
Message 3 of 7

1605027848
Participant
Participant

OK, Thank you, I will wait for a while. If it really doesn't work, I will upload to another forum you suggest.

0 Likes
Message 4 of 7

Ed__Jobe
Mentor
Mentor

The COM api doesn't expose those properties. You will need to use the .NET api. However, you can set the Width of the bounding box in the AddMtext method. In the example in your first post, it's the second argument. You set it at 0. Just change the argument to 50. Or you can prompt the user for a value.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 7

1605027848
Participant
Participant

Thank you, I know AddMText method can pass an argument to change the width of bounding box. so, I guess it can change the width of bounding box, it also can the height of bounding box. That's why I asked if the define height can be changed though COM API, if it can, how to change it, if it can not, then forget it.

0 Likes
Message 6 of 7

Ed__Jobe
Mentor
Mentor
Accepted solution

I'm sorry, the VBA api doesn't have a Height property for the text box. But the .Net api has a TextHeight property.

 

You shouldn't need to set the height. As you add text, it scrolls down to add new lines and the height automatically adjusts. It doesn't stop adding text because the height is too small.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 7

1605027848
Participant
Participant

OK, I know.  Just like you said, when I add text, it scrolls down to add new lines and the height automatically adjusts. Actually, there is an another reason why I want to change the define height of bounding box. Because the drawing is done through COM API, in order to better align the text, I want to modify the defined height of text. Since it can't be modified. Then I can only align it by his InsertPoint property. Thank you very much for your answer!

0 Likes