線形に沿って横断抽出ラインを作成するための最初の手順は、抽出するサーフェスを指定することです。これを行うには、サーフェスを AeccSampleLineGroup.SampledSurfaces コレクションに追加します。 AeccSampledSurfaces.AddAllSurfaces メソッドは、ドキュメント内のサーフェスごとに 1 つの AeccSampledSurface オブジェクトをコレクションに追加します。 AeccSampledSurfaces.Add メソッドは、特定のサーフェス オブジェクトと AeccSectionStyle オブジェクトを取り、追加された AeccSampledSurface オブジェクトの参照を返します。 ブール演算の AeccSampledSurface.Sampleプロパティを True に設定することが重要です。
AeccSampledSurfaces コレクションに追加された Sample Surface オブジェクトの Sample プロパティが True に設定されていない場合、その横断抽出ラインの横断は生成されません。
次の例では、1 つのサーフェスを横断抽出ライン グループに追加する方法と、図面内のすべてのサーフェスを横断抽出ライン グループに追加する方法を示します。
' Get the section style we need for our sampled surface ' object. We use the default style of the document. Dim oSectionStyle As AeccSectionStyle Set oSectionStyle = oDocument.SectionStyles.Item(0) ' Get the surface object we will be sampling from. ' Assume there is a surface with the name "EG". Dim oSurface as AeccSurface Set oSurface = oDocument.Surfaces.Item("EG") ' This section demonstrates adding a single surface to ' the sample line group. An AeccSampleSurface object is ' returned, which needs some properties set. Dim oSampledSurface As AeccSampledSurface Set oSampledSurface = oSampleLineGroup.SampledSurfaces _ .Add(oSurface, oSectionStyle) oSampledSurface.UpdateMode = aeccSectionStateDynamic ' We need to set the Sample property of the ' SampledSurface object. Otherwise the sampled surface ' will not be used in creating sections. oSampledSurface.Sample = True ' This section demonstrates adding all surfaces in the ' document to the sample line group. oSampleLineGroup.SampledSurfaces.AddAllSurfaces oSectionStyle ' We need to set the Sample property of each ' SampledSurface object. Otherwise the sampled surfaces ' will not be used in creating sections. Dim i As Integer For i = 0 To oSampleLineGroup.SampledSurfaces.Count - 1 oSampleLineGroup.SampledSurfaces.Item(i).Sample = True Next i
この時点で、横断抽出ラインを定義できるようになります。横断抽出ラインは、AeccSampleLineGroup.SampleLines コレクションに格納されます。 このコレクションに横断抽出ラインを追加するためのメソッドは、AeccSampleLines.AddByPolyline、AeccSampleLines.AddByStation、および AeccSampleLines.AddByStationRange の 3 つです。
AeccSampledSurfaces コレクションには、パイプ ネットワークやコリドーなど、横断ビューに抽出されるサーフェス以外のオブジェクトを含めることができます。これらのオブジェクトは、AutoCAD Civil 3D ユーザ インタフェースで追加できます(現時点では、API を介して AeccSampledSurfaces コレクションに追加できるのはサーフェスのみです)。
AeccSampledSurface.Surface プロパティを使用してサーフェス以外のオブジェクトにアクセスすると、例外が送出されるため、次の例のように AeccSampledSurface.AcadEntity プロパティを使用する必要があります。この例では、コレクションの 2 番目の項目がパイプ ネットワークになっています。
Dim SampledSurfaces As AeccSampledSurfaces SampledSurfaces = aeccdb.Sites.Item(0).Alignments.Item(1).SampleLineGroups.Item(0).SampledSurfaces Dim s1 As AeccSurface Dim e1 As AcadEntity Dim s2 As AeccPipeNetwork s1 = SampledSurfaces.Item(0).Surface e1 = SampledSurfaces.Item(1).AcadEntity ' Surface would throw exception MessageBox.Show(e1.ObjectName) s2 = e1 MessageBox.Show(s2.Name)
AddByPolyline を使用すると、AutoCAD のライトウェイト ポリライン図形に基づいて横断抽出ラインの位置を指定できます。そのため、横断抽出ラインを非常に柔軟に設計できます。この横断抽出ラインは任意の方向のさまざまな線分セグメントで構成され、線形に対して垂直である必要がなく、線形と交差している必要もありません。AddByPolyline メソッドを使用すると、横断抽出ラインの作成後、ポリライン図形を削除することもできます。 AddByPolyline は、作成された AeccSampleLine オブジェクトを返します。
Dim oPoly As AcadLWPolyline Dim dPoints(0 To 3) As Double ' Assume these coordinates are in one of the surfaces ' in the oSampleLineGroup.SampledSurfaces collection. dPoints(0) = 4750: dPoints(1) = 4050 dPoints(2) = 4770: dPoints(3) = 3950 Set oPoly = ThisDrawing.ModelSpace _ .AddLightWeightPolyline(dPoints) ' Now that we have a polyline, we can create a sample line ' with those coordinates. Delete the polyline when done. Call oSampleLineGroup.SampleLines.AddByPolyline _ ("Sample Line 01", oPoly, True)
AddByStation は、特定の線形測点に対して垂直に 1 本の横断抽出ラインを作成します。 AddByStation メソッドは、パラメータとして横断抽出ラインの名前、そのラインは交差する測点、および線形の左側と右側のラインの長さを取ります。 AddByStation は、作成された AeccSampleLine オブジェクトを返します。
Dim dSwathWidthLeft As Double Dim dSwathWidthRight As Double Dim dStation As Double dSwathWidthRight = 45.5 dSwathWidthLeft = 35.5 dStation = 1100.5 Call oSampleLineGroup.SampleLines.AddByStation( _ "Sample Line 02", _ dStation, _ dSwathWidthLeft, _ dSwathWidthRight)
AddByStationRange は、線形に沿って一連の横断抽出ラインを作成します。横断抽出ラインの特性は、AeccStationRange 型のオブジェクトによって定義されます。AeccStationRange を初めて作成した場合、そのオブジェクト プロパティは既定値に設定されます。このため、すべてのプロパティを希望の値に設定する必要があります。
AeccStationRange.SampleLineStyle プロパティを有効なオブジェクトに設定しなければならないことに注意してください。このようにしない場合、AddByStationRange メソッドでエラーが発生します。
AeccStationRange オブジェクトは、重複の処理方法を指定したフラグとともに AddByStationRange メソッドに渡されます。 次のサンプル行が生成され、AeccSampleLineGroup.SampleLines コレクションに追加されます。 このメソッドには戻り値はありません。
次の例では、線形の横断に沿って一連の横断抽出ラインを追加します。
' Specify where the sample lines will be drawn. Dim oStationRange As New AeccStationRange oStationRange.UseSampleIncrements = True oStationRange.SampleAtHighLowPoints = False oStationRange.SampleAtHorizontalGeometryPoints = False oStationRange.SampleAtSuperelevationCriticalStations = False oStationRange.SampleAtRangeEnd = True oStationRange.SampleAtRangeStart = True oStationRange.StartRangeAtAlignmentStart = False oStationRange.EndRangeAtAlignmentEnd = False ' Only sample for 1000 units along part of the ' alignment. oStationRange.StartRange = 10# oStationRange.EndRange = 1010# ' sample every 200 units along straight lines oStationRange.IncrementTangent = 200# ' sample every 50 units along curved lines oStationRange.IncrementCurve = 50# ' sample every 50 units along spiral lines oStationRange.IncrementSpiral = 50# ' 50 units to either side of the station oStationRange.SwathWidthLeft = 50# oStationRange.SwathWidthRight = 50# oStationRange.SampleLineDefaultDirection = _ aeccDirectionFromBaseAlignment Set oStationRange.SampleLineStyle = oSampleLineStyle oSampleLineGroup.SampleLines.AddByStationRange _ "Sample Line 03", _ aeccSampleLineDuplicateActionOverwrite, _ oStationRange