スタイルは、線形内の方向矢印、曲線、放物線、線分など、線形の作成方法に関するさまざまな側面を定義します。すべての線形スタイルは、CivilDocument.Styles.AlignmentStyles コレクションに含まれています。線形スタイルは、線形オブジェクトによって使用される前にコレクションに追加する必要があります。通常、スタイルは線形が最初に作成されたときにその線形に追加されますが、Alignment.StyleId プロパティを通して既存の線形に割り当てることもできます。
[CommandMethod("SetAlignStyle")] public void SetAlignStyle() { doc = CivilApplication.ActiveDocument; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { // Ask the user to select an 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; // don't show direction arrows myAlignmentStyle.GetDisplayStyleModel(AlignmentDisplayStyleType.Arrow).Visible = false; myAlignmentStyle.GetDisplayStylePlan(AlignmentDisplayStyleType.Arrow).Visible = false; // show curves in violet myAlignmentStyle.GetDisplayStyleModel(AlignmentDisplayStyleType.Curve).Color = Color.FromColorIndex(ColorMethod.ByAci, 200); myAlignmentStyle.GetDisplayStylePlan(AlignmentDisplayStyleType.Curve).Color = Color.FromColorIndex(ColorMethod.ByAci, 200); // show straight sections in blue myAlignmentStyle.GetDisplayStyleModel(AlignmentDisplayStyleType.Line).Color = Color.FromColorIndex(ColorMethod.ByAci, 160); myAlignmentStyle.GetDisplayStylePlan(AlignmentDisplayStyleType.Line).Color = Color.FromColorIndex(ColorMethod.ByAci, 160); // assign style to an existing alignment myAlignment.StyleId = myAlignmentStyle.Id; ts.Commit(); } }