Thawing Layers???

Discussion in 'AutoCAD' started by stck2mlon, Sep 14, 2004.

  1. stck2mlon

    stck2mlon Guest

    I am using the following code but if layer 0 is frozen it errors, what can I do?

    'Thaws, Turns On and Unlocks all layers
    Dim oLayer As AcadLayer
    For Each oLayer In ThisDrawing.Layers
    oLayer.LayerOn = True
    oLayer.Lock = False
    If oLayer.Name <> "0" Then
    oLayer.Freeze = False
    End If
    Next oLayer
     
    stck2mlon, Sep 14, 2004
    #1
  2. stck2mlon

    Jeff Mishler Guest

    Make sure you aren't trying to thaw or turn on the current layer........
     
    Jeff Mishler, Sep 14, 2004
    #2
  3. stck2mlon

    ericju Guest

    Yes, you should be certain that you are not thawing the current layer but looks like that's already handled.

    I have had this problem before: for some properties, trying to reset a property to the same value causes an error.

    So instead of:

    oLayer.LayerOn = True

    You would have:

    ' don't do anything if layer is already on
    if Not oLayer.LayerOn then
    oLayer.LayerOn = True
    end if

    - ej
     
    ericju, Sep 14, 2004
    #3
  4. stck2mlon

    Ed Jobe Guest

    Right, since the current layer can't be frozen, you can't thaw it. Replace
    your IF expression with this one:
    If oLayer.Name <> ThisDrawing.ActiveLayer.Name Then
     
    Ed Jobe, Sep 14, 2004
    #4
  5. stck2mlon

    Ed Jobe Guest

    That will work because the current layer will not be frozen, not because it
    will error when setting it to a value that is already set. His procedure
    works, although redunant. The problem occurs only with the active layer.
    Your method does have good logic though. Why perform an action that doesn't
    need it. However, in this case, I think you wouldn't see any difference in
    performance with either method.

    --
    ----
    Ed
    ----
    looks like that's already handled.
    property to the same value causes an error.
     
    Ed Jobe, Sep 14, 2004
    #5
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.