AddHatch method example


Sub addHatchExample()
    addHatchPreDefined
    addHatchUserDefined
End Sub
Private Sub addHatchUserDefined()
  ' This example creates an associative User defined hatch in model space.
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim patternType As AcPatternType
    Dim bAssociativity As Boolean
    patternName = "_USER"
    patternType = acHatchPatternTypeUserDefined '0
    bAssociativity = True
    Set hatchObj = ThisDrawing.ModelSpace.addHatch(patternType, patternName, bAssociativity)
    Dim outerLoop(0 To 0) As AcadEntity
    Dim center(0 To 2) As Double: center(0) = 10: center(1) = 5: center(2) = 0
    Dim radius As Double: radius = 3
    Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)
    hatchObj.AppendOuterLoop (outerLoop)
    hatchObj.Evaluate
    ThisDrawing.Regen True
End Sub
Private Sub addHatchPreDefined()
  ' This example creates an associative predefined hatch in model space.
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim patternType As AcPatternType
    Dim bAssociativity As Boolean
    patternName = "ANSI31"
    patternType = acHatchPatternTypePreDefined '1
    bAssociativity = True
    Set hatchObj = ThisDrawing.ModelSpace.addHatch(patternType, patternName, bAssociativity)
    Dim outerLoop(0 To 0) As AcadEntity
    Dim center(0 To 2) As Double: center(0) = 5: center(1) = 5: center(2) = 0
    Dim radius As Double: radius = 3
    Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)
    hatchObj.AppendOuterLoop (outerLoop)
    hatchObj.Evaluate
    ThisDrawing.Regen True
End Sub

 


© Bricsys NV. All rights reserved.