xref layer manipulation
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
xref layer manipulation

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
Ryan
Guest





Posted: Wed Dec 29, 2004 1:23 am    Post subject: xref layer manipulation Reply with 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
MP
Guest





Posted: Wed Dec 29, 2004 4:08 am    Post subject: Re: xref layer manipulation Reply with 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...
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 Reply with quote

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 Reply with quote

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 Reply with quote

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
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB