TheSwamp

Code Red => VB(A) => Topic started by: systech on June 17, 2009, 09:28:57 AM

Title: Using VB to select layers
Post by: systech on June 17, 2009, 09:28:57 AM
Guys,
I know that you can turn on/off layers with specific names, but is it possible to do this without knowing the layer names?
Title: Re: Using VB to select layers
Post by: Matt__W on June 17, 2009, 10:09:04 AM
You can use the LIKE function.

Code: [Select]
    For Each lay In lays
        Set color = New AcadAcCmColor
        With color
            .ColorMethod = acColorMethodByACI
            .ColorIndex = "2"
        End With
        [color=red]If UCase$(lay.Name)[/color] [color=blue]Like[/color] [color=red](("*") & ("ALIGN") & ("*")) Then[/color]   [color=green]'This will freeze all layers that contain the word 'align'
                                                                    'Wildcards are used before and after the word[/color]
            lay.TrueColor = color
            lay.Freeze = False
            lay.LayerOn = True
        End If
    Next
Title: Re: Using VB to select layers
Post by: systech on June 17, 2009, 10:15:58 AM
That's cool, but what they're wanting is say you have 10 layers, all named different in different drawings, turn on 1 & turn off the others, then turn on 2 & all others off and so on.  As it was just explained to me after the first conversation about it. :realmad: I love ever changing specs with software development.
Title: Re: Using VB to select layers
Post by: Matt__W on June 17, 2009, 10:19:36 AM
I don't quite understand why you'd want to do that.  But okie-dokie!
Title: Re: Using VB to select layers
Post by: systech on June 17, 2009, 10:42:14 AM
me neither
Title: Re: Using VB to select layers
Post by: Bobby C. Jones on June 17, 2009, 01:11:36 PM
That's cool, but what they're wanting is say you have 10 layers, all named different in different drawings, turn on 1 & turn off the others, then turn on 2 & all others off and so on.  As it was just explained to me after the first conversation about it. :realmad: I love ever changing specs with software development.

sounds like the LAYWALK command
Title: Re: Using VB to select layers
Post by: vegbruiser on August 03, 2009, 09:55:31 AM
That's cool, but what they're wanting is say you have 10 layers, all named different in different drawings, turn on 1 & turn off the others, then turn on 2 & all others off and so on.  As it was just explained to me after the first conversation about it. :realmad: I love ever changing specs with software development.

sounds like the LAYWALK command
That was my first thought on looking at this post.

He really needs to get the spec. nailed down before going any further with this.