| Author |
Message |
Ryan
Guest
|
Posted:
Wed Dec 29, 2004 1:23 am Post subject:
xref layer manipulation |
|
|
I am having trouble trying to change xref layer colors. I want to change
all xref layers with "wtr" in their name to a specified color. Here is what
I have, can anyone tell me why it doesn't work?
Public Sub xreflay()
Dim oLayer As AcadLayer
Dim oLayers As AcadLayers
For Each oLayer In ThisDrawing.Layers
If InStr(1, oLayer.Name, "*|*wtr*") = 0 Then
oLayer.Color = 16
Exit For
End If
Next oLayer
End Sub
Thanks...
|
|
| Back to top |
|
 |
MP
Guest
|
Posted:
Wed Dec 29, 2004 4:08 am Post subject:
Re: xref layer manipulation |
|
|
well, for one thing you might want to review inStr function in help
if you wanted to get a match you probably want "if ... >0 " - meaning you
found a match
instead of "if ... = 0 " meaning you didn't find a match
also you want to look at Like function
since InStr doesn't work with wildcards
Like is the function you want to be using in this case.
also given what you said you wanted to do, you need to lose the Exit for
leaving it in there you will only change the first layer that matches the
string(once you fix that code)
something like
For Each oLayer In ThisDrawing.Layers
If oLayer.Name Like "*|*wtr*" Then
oLayer.Color = 16
End If
Next oLayer
Hth
Mark
"Ryan" <walkerryan@msn.com> wrote in message news:41d1c0d4$1_2@newsprd01...
| Quote: | I am having trouble trying to change xref layer colors. I want to change
all xref layers with "wtr" in their name to a specified color. Here is
what
I have, can anyone tell me why it doesn't work?
Public Sub xreflay()
Dim oLayer As AcadLayer
Dim oLayers As AcadLayers
For Each oLayer In ThisDrawing.Layers
If InStr(1, oLayer.Name, "*|*wtr*") = 0 Then
oLayer.Color = 16
Exit For
End If
Next oLayer
End Sub
Thanks...
|
|
|
| Back to top |
|
 |
Ryan
Guest
|
Posted:
Wed Dec 29, 2004 4:33 am Post subject:
Re: xref layer manipulation |
|
|
Thanks,
I'm sorry I forgot to mention that I'm a novice...
Also for anyone watching this thread the correct syntax is:
For Each oLayer In ThisDrawing.Layers
If oLayer.Name Like "*|*" & "*WTR*" Then
oLayer.Color = 16
End If
Next oLayer
"MP" <nospam@Thanks.com> wrote in message news:41d1e5c2$1_2@newsprd01...
| Quote: | well, for one thing you might want to review inStr function in help
if you wanted to get a match you probably want "if ... >0 " - meaning you
found a match
instead of "if ... = 0 " meaning you didn't find a match
also you want to look at Like function
since InStr doesn't work with wildcards
Like is the function you want to be using in this case.
also given what you said you wanted to do, you need to lose the Exit for
leaving it in there you will only change the first layer that matches the
string(once you fix that code)
something like
For Each oLayer In ThisDrawing.Layers
If oLayer.Name Like "*|*wtr*" Then
oLayer.Color = 16
End If
Next oLayer
Hth
Mark
"Ryan" <walkerryan@msn.com> wrote in message
news:41d1c0d4$1_2@newsprd01...
I am having trouble trying to change xref layer colors. I want to
change
all xref layers with "wtr" in their name to a specified color. Here is
what
I have, can anyone tell me why it doesn't work?
Public Sub xreflay()
Dim oLayer As AcadLayer
Dim oLayers As AcadLayers
For Each oLayer In ThisDrawing.Layers
If InStr(1, oLayer.Name, "*|*wtr*") = 0 Then
oLayer.Color = 16
Exit For
End If
Next oLayer
End Sub
Thanks...
|
|
|
| Back to top |
|
 |
MP
Guest
|
Posted:
Wed Dec 29, 2004 7:46 am Post subject:
Re: xref layer manipulation |
|
|
just curious, did you find a difference between
"*|*" & "*WTR*"
and
"*|*WTR*"
?
"Ryan" <walkerryan@msn.com> wrote in message news:41d1ed5e$1_1@newsprd01...
| Quote: | Thanks,
I'm sorry I forgot to mention that I'm a novice...
|
|
|
| Back to top |
|
 |
caduser77
Guest
|
Posted:
Wed Dec 29, 2004 9:20 am Post subject:
Re: xref layer manipulation |
|
|
Yes,
"*|*" & "*WTR*" worked,
"*|*WTR*" didn't work...
Why, I don't know...
MP wrote:
| Quote: | just curious, did you find a difference between
"*|*" & "*WTR*"
and
"*|*WTR*"
?
"Ryan" <walkerryan@msn.com> wrote in message
news:41d1ed5e$1_1@newsprd01...
Thanks,
I'm sorry I forgot to mention that I'm a novice...
|
|
|
| Back to top |
|
 |
|
|
|
|