• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

select layers that contain a certain text

  • Thread starter Thread starter Rand89
  • Start date Start date

Rand89

Guest
Hello everyone

I should create a macro that selects all the layers whose name ends for a given text, e.g. "_aa", and then layer1_a, layer2_a, layer3_aa, etc., and then freeze them...for the last part I have already found the way it is:
Code:
dim lr as acadlayer
set lr = thisdrawing.layers("layer_aa")
lr.freeze = true
the problem is for the first part, or how to select all layers without having to indicate names one by one...
I've been looking everywhere, but I've only found some code for vb.net.

Thanks :wink:
 
Hello everyone

I should create a macro that selects all the layers whose name ends for a given text, e.g. "_aa", and then layer1_a, layer2_a, layer3_aa, etc., and then freeze them...for the last part I have already found the way it is:
Code:
dim lr as acadlayer
set lr = thisdrawing.layers("layer_aa")
lr.freeze = true
the problem is for the first part, or how to select all layers without having to indicate names one by one...
I've been looking everywhere, but I've only found some code for vb.net.

Thanks :wink:
Well, eventually you have to build a macro that does exactly what you don't want to do manually. . ie you have to take in an array all layers, then for each layer you twist on the right part of the name.. if it is _aa then layer.freeze=true. . .

something like this isomma:
Code:
public sub freeze_layer_aa()
    dim layercoll as acadlayers
    dim i as integer

    set layercoll = thisdrawing.layers

    for i = 0 to layercoll.count - 1
       if right(layercoll.item(i).name, 3) = [B][COLOR="Red"]"_aa"[/COLOR][/B] then
        layercoll.item(i).freeze = true
       end if    
    next i

end sub
 
you obviously have failed to tell you that the same thing you can do as a command line with naked and raw autocad.. .
Code:
-layer.
type an option [?/Def/coRrente/Nuovo/RInomina/ON/OFF/Colore/Tipolinea/SPesslin/TRasparenza/MAte
riali/Stampa/con[B][COLOR="Red"]g[/COLOR][/B]ela/scongela/blocca/unlock/state/description/reconciliar]: [B][COLOR="Red"]g[/COLOR][/B]type name list layer freeze or <selezionare oggetti="">: </selezionare>[B][COLOR="Red"]*_aa[/COLOR][/B]
both the macro and the command you can tie them to a button and with a click you did. .
 
tried, it works to wonder! think how long I lost behind it.. .

thank you very much shape! and say thank you is little..
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top