AUTOCAD Freeze the Plans in VBA

Solved
fabdu91630 -  
fabdu91630 Posted messages 22 Registration date   Status Member Last intervention   -
Hello,

On Autocad 2010

I want to freeze the layers that don't interest me except for one automatically via VBA, does anyone have an idea for the macro, I'm a novice?

Thank you in advance,

Configuration: Windows 7 / Internet Explorer 9.0

2 answers

  1. Baloo
     
    Hello,

    to isolate a layer, there is the command ISOLCALQUE
    conversely, the command ASSOCIERCALQUE restores the layers hidden with ISOLCALQUE.

    These commands are accessible via the toolbars

    so apparently no need for macros.
    0
  2. fabdu91630 Posted messages 22 Registration date   Status Member Last intervention  
     
    This macro allows freezing all layers except those that are needed:
    Sub FreezeAllLayersExceptTwo()
    Dim layer As AcadLayer

    'Loop through all layers in the drawing's Layers collection:
    For Each layer In ThisDrawing.Layers
    'If the layer name is not equal to the name of the layers we don't want to freeze:
    If layer.Name <> "Layer name 1" And layer.Name <> "Layer name 2" Then
    'Freeze the layer except for layer 0 which cannot be frozen
    If layer.Name <> "0" Then layer.Freeze = True
    End If
    Next
    End Sub?
    0