用.Net开发Cad

Cad二次开发

 

如何将新增加的textstyletablerecord设为当前

打印 上一主题 下一主题
Database.Textstyle = Tools.AddTextStyle("断面"); //设置当前文字样式
public static ObjectId AddTextStyle(string StyleName) { ObjectId id; Database db = Tools.Database; DBTransMan tm = Tools.TransactionManager; 
Transaction ta = tm.StartTransaction(); 
TextStyleTable textStyleTable = (TextStyleTable)tm.GetObject(db.TextStyleTableId, OpenMode.ForRead, false); 
if (textStyleTable.Has(StyleName)) 
{ id = textStyleTable[StyleName]; } 
else { textStyleTable.UpgradeOpen(); 
TextStyleTableRecord textStyleRec = new TextStyleTableRecord(); textStyleRec.Name = StyleName;
 textStyleRec.XScale = 0.8; 
textStyleRec.FileName = "romans.shx"; 
textStyleRec.BigFontFileName = "htj_s.shx"; 
id = textStyleTable.Add(textStyleRec); tm.AddNewlyCreatedDBObject(textStyleRec, true); 
}
 ta.Commit(); 
ta.Dispose();
 return id;
 }

posted on 2011-09-19 20:00  xuguangren  阅读(697)  评论(0编辑  收藏  举报

导航