線形は通常、既存のサイトに作成します。個々の AeccSite オブジェクトは、独自の線形コレクションを持っています。このコレクションは、AeccSite.Alignments プロパティの AeccAlignments オブジェクトに保持されます。 また、AeccDocument.AlignmentsSiteless プロパティには、サイトに関連付けられていない線形のコレクションも存在します。
AeccAlignmentsオブジェクトは、新しい線形を作成する 2 通りの方法を提供します。 AeccAlignments.Add メソッドは、線形名、作成先の画層、線形スタイル オブジェクト、および線形ラベル スタイル オブジェクトをパラメータとして取り、新しい空の線形を返します。AeccAlignments.AddFromPolyline メソッドは、同じパラメータに加え、AutoCAD ポリライン図形、分離している線分セグメント間に曲線を追加するかどうかを示すフラグ、および線形の作成後にポリライン図形を消去するかどうかを示すフラグを取ります。
次のコードは、既存のスタイルを使用して 2D ポリラインから線形を作成します。
' Create an alignment style with default settings. Dim oAlignmentStyle as AeccAlignmentStyle Set oAlignmentStyle = oDocument.AlignmentStyles _ .Add("Sample style") ' Create an alignment label style with default settings. Dim oAlignmentLabelStyleSet As AeccAlignmentLabelStyleSet Set oAlignmentLabelStyleSet = oAeccDocument.AlignmentLabelStyleSets _ .Add("Sample label style") ' Get the collection of all siteless alignments. Dim oAlignments as AeccAlignments Set oAlignments = oDocument.AlignmentsSiteless ' Create an empty alignment that draws to layer 0. Dim oAlignment as AeccAlignment Set oAlignment = oAlignments.Add("Sample Alignment", "0", _ oAlignmentStyle.Name, oAlignmentLabelStyleSet.Name) ' Create a simple 2D polyline. Dim oPoly As AcadLWPolyline Dim dPoints(0 To 5) As Double dPoints(0) = 0: dPoints(1) = 600 dPoints(2) = 600: dPoints(3) = 0 dPoints(4) = 1200: dPoints(5) = 600 Set oPoly = oDocument.Database.ModelSpace _ .AddLightWeightPolyline(dPoints) ' Create an alignment from the polyline object. Draw to ' layer 0, erase the polyline when we are done, and ' insert curves between line segments. Set oAlignment = oAlignments.AddFromPolyline( _ "Sample Alignment from Polyline", _ "0", _ oPoly.ObjectID, _ oAlignmentStyle.Name, _ oAlignmentLabelStyleSet.Name, _ True, _ True)
線形は、既存の線形のレイアウトに基づいて作成することもできます。[AeccAlignment.Offset メソッドは、一定のオフセットで新しい線形を作成し、元の線形と同じ親サイトに追加します。 新しい線形は、元の線形と同じ名前(括弧で囲んだ番号が後に付く)と同じスタイルを使用しますが、測点ラベル、ブレーキ測点、設計速度は継承しません。
' Add an offset alignment 10.5 units to the left of the ' original. oAlignment.Offset -10.5