- 积分
- 627
- 明经币
- 个
- 注册时间
- 2016-3-13
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2018-1-19 15:30:53
|
显示全部楼层
第一个问题
public static void SetDimStyleCurrent(string DimStyleName)
{
// Establish connections to the document and its database
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
// Establish a transaction
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead);
ObjectId dimId = ObjectId.Null;
string message = string.Empty;
if (!dst.Has(DimStyleName))
{
CreateModifyDimStyle(DimStyleName, out message);
dimId = dst[DimStyleName];
}
else
dimId = dst[DimStyleName];
DimStyleTableRecord dstr = (DimStyleTableRecord)tr.GetObject(dimId, OpenMode.ForRead);
/* NOTE:
* If this code is used, and the updated style is current,
* an override is created for that style.
* This is not what I wanted.
*/
//if (dstr.ObjectId != db.Dimstyle)
//{
// db.Dimstyle = dstr.ObjectId;
// db.SetDimstyleData(dstr);
//}
/* Simply by running these two lines all the time, any overrides to updated dimstyles get
* cleared away as happens when you select the parent dimstyle in AutoCAD.
*/
db.Dimstyle = dstr.ObjectId;
db.SetDimstyleData(dstr);
tr.Commit();
}
}
关键在于
db.Dimstyle = dstr.ObjectId;
db.SetDimstyleData(dstr);
要两句一起用,我之前也是只用一句,总是有个替代 |
|