Creates a Hatch object.
Supported platforms: Windows only
Signature
VBA:
RetVal = object.AddHatch(PatternType, PatternName, Associativity [, HatchObjectType])
- object
-
Type: Block, ModelSpace, PaperSpace
The objects this method applies to.
- PatternType
-
Access: Input-only
Type: AcPatternType or AcGradientPatternType enum
If the HatchObjectType parameter value is acHatchObject, then use the AcPatternType enum; if the HatchObjectType parameter value is AcGradientObject, then use the AcGradientPatternType enum.
- acHatchPatternTypePredefined: Selects the pattern name from those defined in the acad.pat file.
- acHatchPatternTypeUserDefined: Defines a pattern of lines using the current linetype.
- acHatchPatternTypeCustomDefined: Selects the pattern name from a PAT file other than the acad.pat file.
AcPatternType enum
- acPreDefinedGradient: Selects the fill name from one of the standard values.
- acUserDefinedGradient: Defines a pattern based on property values.
AcGradientPatternType enum
- PatternName
-
Access: Input-only
Type: String
If the HatchObjectType parameter value is acHatchObject, then PatternName should contain the hatch pattern name. If the HatchObjectType parameter value is acGradientObject, then PatternName should contain one of the gradient pattern names listed in GradientName.
- Associativity
-
Access: Input-only
Type: Boolean
- True: The hatch will be associative.
- False: The hatch will not be associative.
- HatchObjectType
-
Access: Input-only
Type: AcHatchObjectType enum
The default value is the AcHatchObjectType enum value of AcHatchObject. If the AcHatchObjectType enum value is AcGradientObject, then PatternType should be of type AcGradientPatternType, and PatternName should contain the gradient pattern name.
Remarks
After the Hatch object is created, you must add the outer loop using the AppendOuterLoop method. The outer loop must be closed and must be created before any inner loops can be created. Inner loops are created one at a time, using the AppendInnerLoop method.
Examples
VBA:
Sub Example_AddHatch() ' This example creates an associative gradient hatch in model space. Dim hatchObj As AcadHatch Dim patternName As String Dim PatternType As Long Dim bAssociativity As Boolean ' Define the hatch patternName = "CYLINDER" PatternType = acPreDefinedGradient '0 bAssociativity = True ' Create the associative Hatch object in model space Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity, acGradientObject) Dim col1 As AcadAcCmColor, col2 As AcadAcCmColor Set col1 = hatchObj.TrueColor Set col2 = hatchObj.TrueColor Call col1.SetRGB(255, 0, 0) Call col2.SetRGB(0, 255, 0) hatchObj.GradientColor1 = col1 hatchObj.GradientColor2 = col2 ' Create the outer boundary for the hatch (a circle) Dim outerLoop(0 To 0) As AcadEntity Dim center(0 To 2) As Double Dim radius As Double center(0) = 3: center(1) = 3: center(2) = 0 radius = 1 Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius) ' Append the outerboundary to the hatch object, and display the hatch hatchObj.AppendOuterLoop outerLoop hatchObj.Evaluate ThisDrawing.Regen True End Sub
Visual LISP:
(vl-load-com) (defun c:Example_AddHatch() ;; This example creates an associative gradient hatch in model space. (setq acadObj (vlax-get-acad-object) doc (vla-get-ActiveDocument acadObj)) ;; Define the hatch (setq patternName "CYLINDER" patternType acPreDefinedGradient bAssociativity :vlax-true) ;; Create the associative Hatch object in model space (setq modelSpace (vla-get-ModelSpace doc) hatchObj (vla-AddHatch modelSpace patternType patternName bAssociativity acGradientObject)) (setq col1 (vla-get-TrueColor hatchObj) col2 (vla-get-TrueColor hatchObj)) (vla-SetRGB col1 255 0 0) (vla-SetRGB col2 0 255 0) (vla-put-GradientColor1 hatchObj col1) (vla-put-GradientColor2 hatchObj col2) ;; Create the outer boundary for the hatch (a circle) (setq center (vlax-3d-point 3 3 0) radius 1 circle (vla-AddCircle modelSpace center radius)) (setq outerLoop (vlax-make-safearray vlax-vbObject '(0 . 0))) (vlax-safearray-put-element outerLoop 0 circle) ;; Append the outerboundary to the hatch object, and display the hatch (vla-AppendOuterLoop hatchObj outerLoop) (vla-Evaluate hatchObj) (vla-Regen doc :vlax-true) )