.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

block textstring's width

2 REPLIES 2
Reply
Message 1 of 3
mpcp
201 Views, 2 Replies

block textstring's width

i insert a block,and the block's textstirng is input by the user, and sometimes the textstring is a litter long, how do i judge the textstring is longer than the block's width. and in textstring,there may contain chinese charactor. thanks
2 REPLIES 2
Message 2 of 3
cadMeUp
in reply to: mpcp

You can try this:

Autodesk.AutoCAD.GraphicsInterface.TextStyle txtStyle = new Autodesk.AutoCAD.GraphicsInterface.TextStyle();
txtStyle.StyleName = "Standard";
txtStyle.TextSize = 1.0;
txtStyle.XScale = 1.0;
txtStyle.Vertical = false;

Extents2d ext = txtStyle.ExtentsBox("TEXTSTRING", true, false, null);
double width = ext.MaxPoint.X - ext.MinPoint.X;
Message 3 of 3
mpcp
in reply to: mpcp

Thanks a lot
and i solve it in another way.
the width is fixed for a block, and the max bytes is also fixed,
so i use System.Text.Encoding.Default.GetByteCount(string) to count all words in bytes number including chinese charactor.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost