原因
lisp语句:
(setvar "dimtxt" 123) ;控制标注高度
当我们使用这些标注样式变量,会令标注出现<样式替代>,那么怎么去掉这个东西呢?
放弃<样式替代>
[CommandMethod("DimRestoreAndEnable")]
public static void DimRestoreAndEnable()
{
Database db = HostApplicationServices.WorkingDatabase;//当前的数据库
Editor ed = Acap.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(Environment.NewLine + "****惊惊连盒-恢复标注替代样式");
db.Action(tr =>
{
var oldDimData = tr.GetObject(db.Dimstyle, OpenMode.ForRead) as DimStyleTableRecord;
db.SetDimstyleData(oldDimData);
});
}
获取<样式替代>并且设置新标注样式
[CommandMethod("DimRestoreAndEnable")]
public static void DimRestoreAndEnable()
{
Database db = HostApplicationServices.WorkingDatabase;//当前的数据库
Editor ed = Acap.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(Environment.NewLine + "****惊惊连盒-恢复标注替代样式");
db.Action(tr =>
{
var currentDimData = db.GetDimstyleData();//临时样式的数据
var dt = tr.GetObject(db.DimStyleTableId, OpenMode.ForRead) as DimStyleTable;
dt.UpgradeOpen();
currentDimData = currentDimData.Clone() as DimStyleTableRecord; //需要与否
currentDimData.Name += "我是新标注样式"; //同时存在的样式,名字冲突了并不会覆盖,后者会变成空白名字在面板上
dt.Add(currentDimData);
tr.AddNewlyCreatedDBObject(currentDimData, true);
db.SetDimstyleData(currentDimData);
});
}
应用<样式替代>到当前标注上
[CommandMethod("DimRestoreAndEnable")]
public static void DimRestoreAndEnable()
{
Database db = HostApplicationServices.WorkingDatabase;//当前的数据库
Editor ed = Acap.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(Environment.NewLine + "****惊惊连盒-恢复标注替代样式");
db.Action(tr =>
{
// 临时样式的数据
var currentDimData = db.GetDimstyleData();
// 当前标注样式
var dim = tr.GetObject(db.Dimstyle, OpenMode.ForRead) as DimStyleTableRecord;
dim.UpgradeOpen();
var name = dim.Name;//名字这些不能删除,否则会变空白
dim.CopyFrom(currentDimData);//复制样式到当前
dim.Name = name;
});
}
如果直接删除<样式替代>宿主,那么它会跑到设定的当前标注上.
(完)