パイプ スタイルを作成する

パイプ スタイルは、ドキュメント内のパイプの外観を制御します。ドキュメント内のすべてのパイプ スタイル オブジェクトは、CivilDocument.PipeStyles collection コレクションに格納されます。パイプ スタイルには、一般的な外観属性を制御するための 4 つの表示メソッドと 3 つのハッチング メソッドと、パイプ固有の表示属性を制御するための 3 つのプロパティがあります。GetDisplayStyleProfile|Section|Plan() および GetH tchStyleProfile() メソッドは変更されるフィーチャを定義するパラメータを取り、共通の表示属性(線分スタイルや色など)を制御する DisplayStyle または HatchDisplayStyle オブジェクトの参照を返します。GetDisplayStyleModel()GetH tchStylePlan()、および GetHatchStyleSection() メソッドはコンポーネント パラメータを取りません。

PlanOption および ProfileOption プロパティは、パイプの物理プロパティ、作図単位を使用するカスタム サイズ、またはその直前の作図サイズのパーセントに基づいて内壁、外壁、および終了ラインのサイズを設定します。HatchOption プロパティは、使用されるハッチングが適用されるパイプ領域を設定します。パイプ オブジェクトには、Pipe.Style プロパティを PipeStyle オブジェクトに割り当てることによってスタイルを設定します。

この例では新規のパイプ スタイル オブジェクトを作成し、そのプロパティの一部を設定します。既に同じ名前のスタイルが存在している場合、その既存のスタイルにプロパティを設定します。

Public Function CreatePipeStyle(ByVal sStyleName As String) As PipeStyle
    Dim oPipeStyleId As ObjectId
    Dim oPipeStyle As PipeStyle
    Dim trans As Transaction = tm.StartTransaction()
    Try
        oPipeStyleId = g_oDocument.Styles.PipeStyles.Add(sStyleName)
    Catch
    End Try
    If (oPipeStyleId = ObjectId.Null) Then
        Try
            oPipeStyleId = g_oDocument.Styles.PipeStyles.Item(sStyleName)
        Catch
        End Try
        If (oPipeStyleId = ObjectId.Null) Then
            MsgBox("Could not create or use a pipe style with the name:" & sStyleName)
            CreatePipeStyle = Nothing
            Exit Function
        End If
    End If
    oPipeStyle = trans.GetObject(oPipeStyleId, OpenMode.ForWrite)
    ' Set the display size of the pipes in plan view.  We will
    ' use absolute drawing units for the inside, outside, and
    ' ends of each pipe.
    ' enter a value greater than or equal to 0.000mm and less than or equal to 1000.000mm
    oPipeStyle.PlanOption.InnerDiameter = 0.0021
    oPipeStyle.PlanOption.OuterDiameter = 0.0024
    ' Indicate that we will use our own measurements for the inside
    ' and outside of the pipe, and not base drawing on the actual
    ' type of pipe.
    oPipeStyle.PlanOption.WallSizeType = PipeWallSizeType.UserDefinedWallSize
    ' Inidcate what kind of custom sizing to use.
    oPipeStyle.PlanOption.WallSizeOptions = PipeUserDefinedType.UseDrawingScale
    oPipeStyle.PlanOption.EndLineSize = 0.0021
    ' Indicate that we will use our own measurements for the end 
    'line of the pipe, and not base drawing on the actual type
    ' of pipe.
    oPipeStyle.PlanOption.EndSizeType = PipeEndSizeType.UserDefinedEndSize
    ' Inidcate what kind of custom sizing to use.
    oPipeStyle.PlanOption.EndSizeOptions = PipeUserDefinedType.UseDrawingScale
    '
    ' Modify the colors of pipes using this style, as shown 
    'in plan view.
    oPipeStyle.GetDisplayStylePlan(PipeDisplayStylePlanType.OutsideWalls).Color = Color.FromRgb(255, 191, 0)  ' orange, ColorIndex = 40
    oPipeStyle.GetDisplayStylePlan(PipeDisplayStylePlanType.InsideWalls).Color = Color.FromRgb(191, 0, 255) ' violet, ColorIndex = 200
    oPipeStyle.GetDisplayStylePlan(PipeDisplayStylePlanType.EndLine).Color = Color.FromRgb(191, 0, 255) ' violet, ColorIndex = 200
    '
    ' Set the hatch style for pipes using this style, as shown 
    'in plan view.
    oPipeStyle.GetHatchStylePlan().Pattern = "DOTS"
    oPipeStyle.GetHatchStylePlan().HatchType = Autodesk.Civil.DatabaseServices.Styles.HatchType.PreDefined
    oPipeStyle.GetHatchStylePlan().UseAngleOfObject = False
    oPipeStyle.GetHatchStylePlan().ScaleFactor = 9.0#
    oPipeStyle.GetDisplayStylePlan(PipeDisplayStylePlanType.Hatch).Color = Color.FromRgb(0, 255, 191) ' turquose, ColorIndex = 120
    oPipeStyle.GetDisplayStylePlan(PipeDisplayStylePlanType.Hatch).Visible = True
    oPipeStyle.PlanOption.HatchOptions = PipeHatchType.HatchToInnerWalls
    trans.Commit()
    ed.WriteMessage("Create PipeStyle succeeded." + Convert.ToChar(10))
    CreatePipeStyle = oPipeStyle
End Function ' CreatePipeStyle