Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Stripping...... :-) Characters from Layer Names

16 REPLIES 16
Reply
Message 1 of 17
Anonymous
410 Views, 16 Replies

Stripping...... :-) Characters from Layer Names

Say I have layers named "LAYER1XX", LAYER2XX, LAYER3XX, etc. and I want to strip the "XX" from the layer names. How and what would be the best way to do this?

TIA

"Catch" Ya Later,
Tim
16 REPLIES 16
Message 2 of 17
Anonymous
in reply to: Anonymous

You could use rename *xx to ?????? will strip the
xx.

 

Dave Alexander


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Say
I have layers named "LAYER1XX", LAYER2XX, LAYER3XX, etc. and I want to strip
the "XX" from the layer names. How and what would be the best way to do this?

TIA

"Catch" Ya Later,
Tim

Message 3 of 17
Anonymous
in reply to: Anonymous

Dave,
Cool. But, if I wanted just to strip the XX from the layer name and leave the rest of the layer name as it was. I.e. LAYER1XX >>>> LAYER1 ????

"Catch" Ya Later,
Tim
Message 4 of 17
Anonymous
in reply to: Anonymous

I thought that is what it does. I tested it and it
worked.

 

Dave Alexander

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Dave,

Cool. But, if I wanted just to strip the XX from the layer name and leave
the rest of the layer name as it was. I.e. LAYER1XX >>>> LAYER1
????

"Catch" Ya Later,
Tim

Message 5 of 17
Anonymous
in reply to: Anonymous

I have about 100 layer names to do this function to. 🙂
Message 6 of 17
Anonymous
in reply to: Anonymous

If the layer names are not all the same length then
I would use rename ??xx to ?? and simply do another rename for layer names with
???xx and so on. Not automatic as with a specific rename lisp but what the hey,
low tech is not all that bad.

 

Dave Alexander


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
have about 100 layer names to do this function to.
:-)
Message 7 of 17
Anonymous
in reply to: Anonymous

Hey, I am low tech compatible. 🙂 Pretty much all the code I write is low tech. Good idea Dave. Thanks. Will work with that until...or unless I get another idea. Thanks.

Tim
Message 8 of 17
Anonymous
in reply to: Anonymous

Their is really only one Religion, just different versions of it.

(defun C:lay_trim ()
(vl-load-com)
(vlax-map-collection
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
'(lambda (x)
(vla-put-name
x
(vl-string-right-trim
"XX";;;characters to trim (case sensitive)
(vla-get-name x)))
)
)
(princ)
)

--
Ken Alexander
Acad2000
Windows2000 Prof.

"We can't solve problems by using the same kind
of thinking we used when we created them."
--Albert Einstein

"TJARONIK" wrote in message
news:f1856a3.5@WebX.maYIadrTaRb...
> Hey, I am low tech compatible. 🙂 Pretty much all the code I write
is low tech. Good idea Dave. Thanks. Will work with that until...or
unless I get another idea. Thanks.
> Tim
>
Message 9 of 17
Anonymous
in reply to: Anonymous

Thanks Ken,

Dave Alexander

"Ken Alexander" wrote in message
news:D98BC4973CD6288CC797375169144A39@in.WebX.maYIadrTaRb...
> Their is really only one Religion, just different versions of it.
>
> (defun C:lay_trim ()
> (vl-load-com)
> (vlax-map-collection
> (vla-get-layers
> (vla-get-activedocument
> (vlax-get-acad-object)))
> '(lambda (x)
> (vla-put-name
> x
> (vl-string-right-trim
> "XX";;;characters to trim (case sensitive)
> (vla-get-name x)))
> )
> )
> (princ)
> )
>
> --
> Ken Alexander
> Acad2000
> Windows2000 Prof.
>
> "We can't solve problems by using the same kind
> of thinking we used when we created them."
> --Albert Einstein
>
> "TJARONIK" wrote in message
> news:f1856a3.5@WebX.maYIadrTaRb...
> > Hey, I am low tech compatible. 🙂 Pretty much all the code I write
> is low tech. Good idea Dave. Thanks. Will work with that until...or
> unless I get another idea. Thanks.
> > Tim
> >
>
>
Message 10 of 17
Anonymous
in reply to: Anonymous

You're Welcome.

--
Ken Alexander
Acad2000
Windows2000 Prof.

"We can't solve problems by using the same kind
of thinking we used when we created them."
--Albert Einstein

"Dave Alexander" wrote in
message news:EB634BDDE8FBD129DE851A1421086E07@in.WebX.maYIadrTaRb...
> Thanks Ken,
>
> Dave Alexander
>
> "Ken Alexander" wrote in message
> news:D98BC4973CD6288CC797375169144A39@in.WebX.maYIadrTaRb...
> > Their is really only one Religion, just different versions of it.
> >
> > (defun C:lay_trim ()
> > (vl-load-com)
> > (vlax-map-collection
> > (vla-get-layers
> > (vla-get-activedocument
> > (vlax-get-acad-object)))
> > '(lambda (x)
> > (vla-put-name
> > x
> > (vl-string-right-trim
> > "XX";;;characters to trim (case sensitive)
> > (vla-get-name x)))
> > )
> > )
> > (princ)
> > )
> >
> > --
> > Ken Alexander
> > Acad2000
> > Windows2000 Prof.
> >
> > "We can't solve problems by using the same kind
> > of thinking we used when we created them."
> > --Albert Einstein
> >
> > "TJARONIK" wrote in message
> > news:f1856a3.5@WebX.maYIadrTaRb...
> > > Hey, I am low tech compatible. 🙂 Pretty much all the code I
write
> > is low tech. Good idea Dave. Thanks. Will work with that
until...or
> > unless I get another idea. Thanks.
> > > Tim
> > >
> >
> >
>
>
Message 11 of 17
Anonymous
in reply to: Anonymous

Ken,

I tried to modify the file to trim off the xref bind part of the layer
names, ie. 41261AWA$0$A-FLOR-CASE to A-FLOR-CASE and it doesn't do it.

Dave Alexander

"Ken Alexander" wrote in message
news:B940FA09B3C9AF8D4DB8548D9B005768@in.WebX.maYIadrTaRb...
> You're Welcome.
>
> --
> Ken Alexander
> Acad2000
> Windows2000 Prof.
>
> "We can't solve problems by using the same kind
> of thinking we used when we created them."
> --Albert Einstein
>
Message 12 of 17
Anonymous
in reply to: Anonymous

well, how'd you modify it?
the routine stripped chars from end of string, not beginning.

does this work?
(defun C:temp-lay_trim ()
(vl-load-com)
(vlax-map-collection
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
'(lambda (x)
(vla-put-name
x
(vl-string-left-trim
"41261AWA$0$";;;characters to trim (case sensitive)
(vla-get-name x)))
)
)
(princ)
)

"Dave Alexander" wrote in message
news:6E8DCD895F2393A64E135B790D4CFD79@in.WebX.maYIadrTaRb...
> Ken,
>
> I tried to modify the file to trim off the xref bind part of the layer
> names, ie. 41261AWA$0$A-FLOR-CASE to A-FLOR-CASE and it doesn't do it.
>
> Dave Alexander
>
> "Ken Alexander" wrote in message
> news:B940FA09B3C9AF8D4DB8548D9B005768@in.WebX.maYIadrTaRb...
> > You're Welcome.
> >
> > --
> > Ken Alexander
> > Acad2000
> > Windows2000 Prof.
> >
> > "We can't solve problems by using the same kind
> > of thinking we used when we created them."
> > --Albert Einstein
> >
>
>
>
Message 13 of 17
Anonymous
in reply to: Anonymous

Dave,

Notice in Mark's post, he replaced vl-string-right-trim with
vl-string-left-trim. You could have also used vl-string-trim, this
will remove the specified characters from the beginning and/or end.

--
Ken Alexander
Acad2000
Windows2000 Prof.

"We can't solve problems by using the same kind
of thinking we used when we created them."
--Albert Einstein

"Dave Alexander" wrote in
message news:6E8DCD895F2393A64E135B790D4CFD79@in.WebX.maYIadrTaRb...
> Ken,
>
> I tried to modify the file to trim off the xref bind part of the
layer
> names, ie. 41261AWA$0$A-FLOR-CASE to A-FLOR-CASE and it doesn't do
it.
>
> Dave Alexander
>
> "Ken Alexander" wrote in message
> news:B940FA09B3C9AF8D4DB8548D9B005768@in.WebX.maYIadrTaRb...
> > You're Welcome.
> >
> > --
> > Ken Alexander
> > Acad2000
> > Windows2000 Prof.
> >
> > "We can't solve problems by using the same kind
> > of thinking we used when we created them."
> > --Albert Einstein
> >
>
>
>
Message 14 of 17
Anonymous
in reply to: Anonymous

Thanks Ken, and Mark,

But it doesn't work. I am not being critical. My lisp is usually based on
someone elses work and I then modify it to suit my particualiar needs with
suitable credit to the original source (now that I am saving the original
source).
I think the problem is with the wildcard characters as I did originally
change it to vl-string-left-trim using *$0$ which didn't work.

I will try the vl-string-trim and see how that works.

Thanks again.

Dave Alexander

"Ken Alexander" wrote in message
news:8DBD317AED1A516414F97835A21FB054@in.WebX.maYIadrTaRb...
> Dave,
>
> Notice in Mark's post, he replaced vl-string-right-trim with
> vl-string-left-trim. You could have also used vl-string-trim, this
> will remove the specified characters from the beginning and/or end.
>
> --
> Ken Alexander
> Acad2000
> Windows2000 Prof.
>
> "We can't solve problems by using the same kind
> of thinking we used when we created them."
> --Albert Einstein
>
> "Dave Alexander" wrote in
> message news:6E8DCD895F2393A64E135B790D4CFD79@in.WebX.maYIadrTaRb...
> > Ken,
> >
> > I tried to modify the file to trim off the xref bind part of the
> layer
> > names, ie. 41261AWA$0$A-FLOR-CASE to A-FLOR-CASE and it doesn't do
> it.
> >
> > Dave Alexander
> >
> > "Ken Alexander" wrote in message
> > news:B940FA09B3C9AF8D4DB8548D9B005768@in.WebX.maYIadrTaRb...
> > > You're Welcome.
> > >
> > > --
> > > Ken Alexander
> > > Acad2000
> > > Windows2000 Prof.
> > >
> > > "We can't solve problems by using the same kind
> > > of thinking we used when we created them."
> > > --Albert Einstein
> > >
> >
> >
> >
>
>
Message 15 of 17
Anonymous
in reply to: Anonymous

He is one way of searching for a pattern and trimming
it and all characters to the left.

;;;Looks for pattern and
;;;trims left side of string
;;;of the pattern and characters
;;;to the left of pattern.

(defun C:lay_trim (/ str searchstr)
(vl-load-com)
(vlax-map-collection
(vla-get-layers
(vla-get-activedocument
(vlax-get-acad-object)))
'(lambda (x)
(setq str (vla-get-name x)
searchstr "$0$");;;set your pattern here
(if (vl-string-search searchstr str)
(vla-put-name x
(vl-string-left-trim
(substr str
1
(+ (strlen searchstr)
(vl-string-search searchstr str))
)
str
)
)
)
)
)
(princ)
)

--
Ken Alexander
Acad2000
Windows2000 Prof.

"We can't solve problems by using the same kind
of thinking we used when we created them."
--Albert Einstein

"Dave Alexander" wrote in
message news:EFC3AD8B6BEDB043AE216464ABFFFE0F@in.WebX.maYIadrTaRb...
> Thanks Ken, and Mark,
>
> But it doesn't work. I am not being critical. My lisp is usually
based on
> someone elses work and I then modify it to suit my particualiar
needs with
> suitable credit to the original source (now that I am saving the
original
> source).
> I think the problem is with the wildcard characters as I did
originally
> change it to vl-string-left-trim using *$0$ which didn't work.
>
> I will try the vl-string-trim and see how that works.
>
> Thanks again.
>
> Dave Alexander
>
> "Ken Alexander" wrote in message
> news:8DBD317AED1A516414F97835A21FB054@in.WebX.maYIadrTaRb...
> > Dave,
> >
> > Notice in Mark's post, he replaced vl-string-right-trim with
> > vl-string-left-trim. You could have also used vl-string-trim,
this
> > will remove the specified characters from the beginning and/or
end.
> >
> > --
> > Ken Alexander
> > Acad2000
> > Windows2000 Prof.
> >
> > "We can't solve problems by using the same kind
> > of thinking we used when we created them."
> > --Albert Einstein
> >
> > "Dave Alexander" wrote in
> > message
news:6E8DCD895F2393A64E135B790D4CFD79@in.WebX.maYIadrTaRb...
> > > Ken,
> > >
> > > I tried to modify the file to trim off the xref bind part of the
> > layer
> > > names, ie. 41261AWA$0$A-FLOR-CASE to A-FLOR-CASE and it doesn't
do
> > it.
> > >
> > > Dave Alexander
> > >
> > > "Ken Alexander" wrote in message
> > > news:B940FA09B3C9AF8D4DB8548D9B005768@in.WebX.maYIadrTaRb...
> > > > You're Welcome.
> > > >
> > > > --
> > > > Ken Alexander
> > > > Acad2000
> > > > Windows2000 Prof.
> > > >
> > > > "We can't solve problems by using the same kind
> > > > of thinking we used when we created them."
> > > > --Albert Einstein
> > > >
> > >
> > >
> > >
> >
> >
>
>
Message 16 of 17
Anonymous
in reply to: Anonymous

You guys & gals are simply AWESOME. You have made my job soooooooooooooooo much easier. I have taken your suggestions on code along with my own scribblings and added them to one master lisp routine. The old way of doing things normally took anywhere from 10 - 15 minutes per drawing and now with this master lisp routine, it takes less than 5 seconds. I have been working on updating literally hundreds of drawings. Last count I believe it was over 700 drawings. No kidding. Now, with this routine. I can clean these drawings up and save myself not only an extremely large amount of time, but thousands upon thousands of key strokes. It is just plain awesome. FANTASTIC. This is the way Autocad is meant to be done. Again, THANK YOU ALL!! You guys and gals are simply AWESOME.

"Catch" Ya Later,
Tim
Message 17 of 17
Anonymous
in reply to: Anonymous

That is just too slick! Thanks for this fabulous .lsp routine!!! A wonderful "clean-up" tool.

K.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report