我们在程序中, 经常会遇到用代码去改变文字的问题。 一般的思维就是设置CADText.Text 。 但是使用CADText.Text =xxx不会更新视图。所以要改变dwg中文字, 需要更多的C#代码手动的刷新视图。
04
|
private void ChangeText(string textValue, string newValue)
|
06
|
foreach (CADEntity entity in cadImage.Converter.Entities)
|
08
|
if (entity.EntType == EntityType.Text)
|
10
|
CADText cadText = entity as CADText;
|
11
|
if (cadText.Text == textValue)
|
13
|
cadText.Text = newValue;
|
14
|
cadImage.Converter.Loads(cadText);
|
15
|
cadImage.GetExtents();
|
另外, 提供的 CADMText 类默认就是支持多行的文字,如果你只想显示单行的文字, 唯一的办法就是先删除多行文字, 然后在新建一个MText 类, 把多行的文字拷贝过去。
阅读(1035) | 评论(0) | 转发(0) |