How is the vba-command tu use hatch?

Discussion in 'AutoCAD' started by Jürg Menzi, Jul 1, 2003.

  1. Jürg Menzi

    Jürg Menzi Guest

    Hartmut

    From Help:

    RetVal = object.AddHatch(PatternType, PatternName, Associativity)

    Object ModelSpace Collection, PaperSpace Collection, Block
    The object or objects this method applies to.

    PatternType AcPatternType enum; input-only
    acHatchPatternTypePredefined
    acHatchPatternTypeUserDefined
    acHatchPatternTypeCustomDefined

    PatternName String; input-only
    The name of the hatch pattern to be used.

    Associativity Boolean; input-only
    TRUE: The hatch will be associative.
    FALSE: The hatch will not be associative.

    RetVal Hatch object
    The newly created Hatch object.

    Remarks:
    The PatternType constant values are as follows:
    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 other than the acad.pat file.
    Once the Hatch object has been created, you must then 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.
    WARNING! Once the Hatch object has been created, you must append the outer
    loop to the Hatch object for it to become a valid AutoCAD object. If you
    attempt any operation other than calling the AppendOuterLoop method,
    AutoCAD will enter an unpredictable state.

    Cheers
     
    Jürg Menzi, Jul 1, 2003
    #1
  2. Hallo,
    how is the vba-command tu use hatch (acad2000)? Not with
    ThisDrawing.SendCommand.
    I didn't find the help from acad-vba.

    I must hatch a circle.

    Thanks.
    Hartmut Callies
     
    Hartmut Callies, Jul 1, 2003
    #2
  3.  

    Thank you. Your help was very good.



    Now I have a circle with text. When I use the autocad-command "bhatch" then the hatch not above the text. The vba-command "ThisDrawing.ModelSpace.AddHatch ..." hatch also the text. I must have a result how "bhatch". Can I get with the vba-command or must I do that with many code? 



    Thanks.



    Hartmut Callies





     



    "Mark_Abercrombie" <> schrieb im Newsbeitrag news:...

    Here's a snippet of code from one of my projects that hatches a circle:

    If Entity.ObjectName = "AcDbCircle" Then   Set ACircle = Entity   Set OuterLoop(0) = ACircle   Set Hatch = ThisDrawing.ModelSpace.AddHatch _     (acHatchPatternTypePreDefined, "SOLID", True)   Hatch.AppendOuterLoop OuterLoop   Hatch.Evaluate   Hatch.Update End If
     
    Hartmut Callies, Jul 1, 2003
    #3
  4. Jürg Menzi

    Jürg Menzi Guest

    Hartmut

    Based on Mark's sample:

    Public Function TestHatch()

    Dim ACircle As AcadCircle
    Dim ACtext As AcadText
    Dim AChatch As AcadHatch
    Dim InsPnt(0 To 2) As Double
    Dim OuterLoop(0 To 0) As AcadEntity
    Dim InnerLoop(0 To 0) As AcadEntity

    InsPnt(0) = 0#
    InsPnt(1) = 0#
    InsPnt(2) = 0#

    Set ACircle = ThisDrawing.ModelSpace.AddCircle(InsPnt, 50#)
    Set ACtext = ThisDrawing.ModelSpace.AddText("Hello", InsPnt, 10#)

    Set OuterLoop(0) = ACircle
    Set InnerLoop(0) = ACtext
    Set AChatch = ThisDrawing.ModelSpace.AddHatch _
    (acHatchPatternTypePreDefined, "SOLID", True)
    AChatch.AppendOuterLoop OuterLoop
    AChatch.AppendInnerLoop InnerLoop
    AChatch.Evaluate
    AChatch.Update

    End Function

    Cheers
     
    Jürg Menzi, Jul 2, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.