Fatal Error When I Regen

Discussion in 'AutoCAD' started by Chris Picklesimer, Jul 11, 2003.

  1. I have had a problem (VBA 2000 & 2004) with ThisDrawing.Regen
    acActiveViewport. Occasionally I get a fatal error(FATAL Error: Unhandled
    Access Violation Reading 0x0000 Exception at ????? ). I pass a string of
    layers (format: "Layer1,Layer2,Layer3") into the sub below and when there is
    a crash, the crash point is always the line: ThisDrawing.Regen
    acActiveViewport. Before and after this sub, I am changing layouts and
    plotting. I have noticed when in 2004 that if I set the LAYOUTREGENCTL to
    0, all seems to work fine. I would like to get this to work for both 2000
    (2000 does not have LAYOUTREGENCTL variable) & 2004. Does anyone have any
    insight on what is causing the problem?

    Thanks.

    Chris


    Private Sub TurnOnLayers(strPassedLayers As String)
    Dim objLayer As AcadLayer
    Dim strLayer As String

    ThisDrawing.ActiveLayout = ThisDrawing.Layouts("Model")
    If ThisDrawing.Layers("0").Freeze = True Then
    ThisDrawing.Layers("0").Freeze = False
    End If

    ThisDrawing.ActiveLayer = ThisDrawing.Layers("0")
    ThisDrawing.Application.Update

    On Error Resume Next
    For Each objLayer In ThisDrawing.Layers
    objLayer.Freeze = True
    Next objLayer

    strLayer = ""

    Dim i As Long
    For i = 1 To Len(strPassedLayers)
    If Mid$(strPassedLayers, i, 1) = "," Or i = Len(strPassedLayers) Then
    If i = Len(strPassedLayers) Then
    strLayer = strLayer & Mid$(strPassedLayers, i, 1)
    End If
    On Error Resume Next
    ThisDrawing.Layers(strLayer).Freeze = False
    On Error Resume Next
    ThisDrawing.Layers(strLayer).LayerOn = True
    strLayer = ""
    Else
    strLayer = strLayer & Mid$(strPassedLayers, i, 1)
    End If

    Next i

    ThisDrawing.Regen acActiveViewport

    End Sub
     
    Chris Picklesimer, Jul 11, 2003
    #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.