Auto Hatch entities with execution error

Discussion in 'AutoCAD' started by GerardK, Jan 6, 2005.

  1. GerardK

    GerardK Guest

    Hello all,

    When running this code, autocad (2004) gives me a Execution error.
    This error comes from "For Each objAcadEntity In objSSet, next".
    How can I solve this problem??

    Newby on VBA,
    Gerard

    'Public Sub MakeHatchesFromLayer(myLayerName As String)
    Dim arrOuterLoop(0) As AcadEntity
    Dim objAcadHatch As AcadHatch
    Dim objSSet As AcadSelectionSet
    Dim objAcadEntity As AcadEntity
    Dim gpCode(0 To 1) As Integer
    Dim gpValue(0 To 1) As Variant

    On Error GoTo ErrMakeHatchesFromLayer:

    Set objSSet = ThisDrawing.SelectionSets.Add("SSet_MakeHatches")

    gpCode(0) = 8: gpValue(0) = myLayerName
    gpCode(1) = 0: gpValue(1) = "LWPOLYLINE"
    objSSet.Select acSelectionSetAll, , , gpCode, gpValue

    For Each objAcadEntity In objSSet ''''''''''ERROR why ??
    If objAcadEntity.Closed Then
    Set arrOuterLoop(0) = objAcadEntity
    Set objAcadHatch = ThisDrawing.ModelSpace.AddHatch(acHatchPatternTypePreDefined, "SOLID", True)

    objHatch.AppendOuterLoop objPline

    objAcadHatch.AppendOuterLoop arrOuterLoop
    objAcadHatch.Evaluate
    objAcadHatch.Layer = myLayerName
    End If
    Next

    ExitErrMakeHatchesFromLayer:
    objSSet.Delete
    Exit Sub

    ErrMakeHatchesFromLayer:

    MsgBox "Error : " & Err.Number & " - " & Err.Description
    GoTo ExitErrMakeHatchesFromLayer:
    End Sub
     
    GerardK, Jan 6, 2005
    #1
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.