Tất cả các màu sắc đường thẳng, đường cong, mũi tên chỉ hướng.. của Alignment đều được chứa trong tập hợp CivilDocument.Styles.AlignmentStyles. Bài hướng dẫn sau giúp ta thiết lập được cách thiết lập kiểu hiển thị trên 1 Alignment:
[CommandMethod("SetAlignStyle")] public void SetAlignStyle() { doc = CivilApplication.ActiveDocument; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { // Chọn Alignment PromptEntityOptions opt = new PromptEntityOptions("\nSelect an Alignment"); opt.SetRejectMessage("\nObject must be an alignment.\n"); opt.AddAllowedClass(typeof(Alignment), false); ObjectId alignID = ed.GetEntity(opt).ObjectId; Alignment myAlignment = ts.GetObject(alignID, OpenMode.ForWrite) as Alignment; ObjectId styleID = doc.Styles.AlignmentStyles.Add("Sample alignment style"); AlignmentStyle myAlignmentStyle = ts.GetObject(styleID, OpenMode.ForWrite) as AlignmentStyle; // Không hiển thị mũi tên chỉ hướng myAlignmentStyle.GetDisplayStyleModel(AlignmentDisplayStyleType.Arrow).Visible = false; myAlignmentStyle.GetDisplayStylePlan(AlignmentDisplayStyleType.Arrow).Visible = false; // Hiển thị đường cong trên tuyến có dạng màu tím myAlignmentStyle.GetDisplayStyleModel(AlignmentDisplayStyleType.Curve).Color = Color.FromColorIndex(ColorMethod.ByAci, 200); myAlignmentStyle.GetDisplayStylePlan(AlignmentDisplayStyleType.Curve).Color = Color.FromColorIndex(ColorMethod.ByAci, 200); // Hiển thị đường thẳng dạng màu xanh myAlignmentStyle.GetDisplayStyleModel(AlignmentDisplayStyleType.Line).Color = Color.FromColorIndex(ColorMethod.ByAci, 160); myAlignmentStyle.GetDisplayStylePlan(AlignmentDisplayStyleType.Line).Color = Color.FromColorIndex(ColorMethod.ByAci, 160); // Gán thuộc tính khai báo trên cho tuyến myAlignment.StyleId = myAlignmentStyle.Id; // Cập nhập dữ liệu ts.Commit(); } }