Author Topic: Using VB to select layers  (Read 1954 times)

0 Members and 1 Guest are viewing this topic.

systech

  • Guest
Using VB to select layers
« 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?

Matt__W

  • Seagull
  • Posts: 12954
  • I like my water diluted.
Re: Using VB to select layers
« Reply #1 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
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

systech

  • Guest
Re: Using VB to select layers
« Reply #2 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.

Matt__W

  • Seagull
  • Posts: 12954
  • I like my water diluted.
Re: Using VB to select layers
« Reply #3 on: June 17, 2009, 10:19:36 AM »
I don't quite understand why you'd want to do that.  But okie-dokie!
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

systech

  • Guest
Re: Using VB to select layers
« Reply #4 on: June 17, 2009, 10:42:14 AM »
me neither

Bobby C. Jones

  • Swamp Rat
  • Posts: 514
  • Cry havoc and let loose the dogs of war.
Re: Using VB to select layers
« Reply #5 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
Bobby C. Jones

vegbruiser

  • Guest
Re: Using VB to select layers
« Reply #6 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.