Edit Hatch Patterns

AutoCAD ActiveX

 
Edit Hatch Patterns
 
 
 

You can change the angle or spacing of an existing hatch pattern or replace it with a solid-fill or one of the predefined patterns that AutoCAD offers. The Pattern option in the Boundary Hatch dialog box displays a list of these patterns. To reduce file size, the hatch is defined in the drawing as a single graphic object.

Use the following properties and methods to edit the hatch patterns:

PatternAngle

Specifies the angle of the hatch pattern.

PatternDouble

Specifies if the user-defined hatch is double-hatched.

PatternName

Specifies the hatch pattern name (does not change the pattern type).

PatternScale

Specifies the hatch pattern scale.

PatternSpace

Specifies the user-defined hatch pattern spacing.

SetPattern

Sets the pattern name and pattern type for the hatch.

Change the pattern spacing of a hatch

This example creates a hatch. It then adds two to the current pattern spacing for the hatch.

Sub Ch4_ChangeHatchPatternSpace()
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim PatternType As Long
    Dim bAssociativity As Boolean
      
    ' Define the hatch
    patternName = "ANSI31"
    PatternType = 0
    bAssociativity = True
      
    ' Create the associative Hatch object
    Set hatchObj = ThisDrawing.ModelSpace. _
        AddHatch(PatternType, patternName, bAssociativity)
      
    ' Create the outer loop for the hatch.
    Dim outerLoop(0 To 0) As AcadEntity
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 5
    center(1) = 3
    center(2) = 0
    radius = 3
    Set outerLoop(0) = ThisDrawing.ModelSpace. _
 AddCircle(center, radius)
    hatchObj.AppendOuterLoop (outerLoop)
    hatchObj.Evaluate
      
    ' Change the spacing of the hatch pattern by
    ' adding 2 to the current spacing
    hatchObj.patternSpace = hatchObj.patternSpace + 2
    hatchObj.Evaluate
    ThisDrawing.Regen True
End Sub