如何创建多线样式(MlineStyle)?
如何创建多线样式(MlineStyle)?已经解决 本帖最后由 kuaigoumanzhu 于 2012-4-21 17:48 编辑
解决了就应该贴出来,大家才能互相帮助! using (Transaction ctrans = db.TransactionManager.StartTransaction())
{
DBDictionary mlDict= (DBDictionary)ctrans.GetObject(db.MLStyleDictionaryId, OpenMode.ForWrite);
if (mlDict.Contains("M2"))
{
se.WriteMessage("\nM2 已存在");
}
else
{
MlineStyle mlStyle = new MlineStyle();
mlStyle.Name = "M2";
mlStyle.StartAngle = sCon.PI90;
mlStyle.EndAngle = sCon.PI90;
MlineStyleElement mlElement1 = new MlineStyleElement(1, Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 1), ObjectId.Null);
mlStyle.Elements.Add(mlElement1, true);
MlineStyleElement mlElement2 = new MlineStyleElement(-2, Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 2), ObjectId.Null);
mlStyle.Elements.Add(mlElement2, true);
mlDict.SetAt(mlStyle.Name, mlStyle);
ctrans.AddNewlyCreatedDBObject(mlStyle, true);
}
ctrans.Commit();
}
页:
[1]