Jump to content

Recommended Posts

Posted

I have a drawing i need to simply change the leading letters of the layer (C-***) to V-***.

 

anyway to Find and Replace?

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    7

  • Tharwat

    6

  • BlackBox

    5

  • baker

    3

Top Posters In This Topic

Posted Images

Posted

Try this baker and it is case sensitive which means ( c- (small letter) is not equal to C- (capital letter)) .

 

Codes better than Command calls . :D

(defun c:TesT (/ nxt layrs Nme)
 ;; == TharwaT 01. 09. 2011 == ;;
 (while
   (setq nxt (tblnext "LAYER" (null nxt)))
    (setq
      layrs
       (entget (tblobjname "LAYER" (setq Nme (cdr (assoc 2 nxt)))))
    )
    (if (and (not (eq Nme "0"))
             (eq (vl-string-search "C-" Nme 0) 0)
        )
      (entmod
        (subst (cons 2 (vl-string-subst "V-" "C-" (cdr (assoc 2 layrs))))
               (assoc 2 layrs)
               layrs
        )
      )
    )
 )
 (princ)
)

 

Tharwat

Posted
(eq (vl-string-search "C-" Nme 0) 0)

 

*cough* wcmatch *cough*

 

 

But I try not to re-invent the wheel where possible ;)

Posted
*cough* wcmatch *cough*

But I try not to re-invent the wheel where possible ;)

 

I have thought of that as another access to Layer name matches and I do agree that the function wcmatch is much better than vl-string-search in this case .

 

Anyway here it goes .

 

Comments are also welcomed . :)

 

(defun c:TesT (/ nxt layrs Nme)
 ;; == TharwaT 01. 09. 2011 == ;;
 (while
   (setq nxt (tblnext "LAYER" (null nxt)))
    (setq
      layrs
       (entget (tblobjname "LAYER" (setq Nme (cdr (assoc 2 nxt)))))
    )
    (if (and (not (eq Nme "0"))
             (wcmatch Nme "C-*")
        )
      (entmod
        (subst (cons 2 (vl-string-subst "V-" "C-" (cdr (assoc 2 layrs))))
               (assoc 2 layrs)
               layrs
        )
      )
    )
 )
 (princ)
)

Posted

Tharwat,

 

Not that you have to of course, but out of curiosity... if you're not going to use the RENAME command, and you're going to use vl-* functions, then why not just iterate the Layers Collection instead? :unsure:

 

Pseudo code:

 

((lambda (acDoc / )
 (vlax-for lay (vla-get-layers acDoc)
   [color=seagreen];;<-- Check / rename layers here[/color]
   )
 )
 (vla-get-activedocument (vlax-get-acad-object)))

Posted
.. if you're not going to use the RENAME command,

 

If you have many layers (maybe Hundreds) in a dwg , the command call would be lazy .:)

 

and you're going to use vl-* functions, then why not just iterate the Layers Collection instead? :unsure:

 

Both are the same , aren't they ?

 

One more routine in Vl .:)

 

(defun c:TesT (/ lays Nme)
 ;; == TharwaT 01. 09. 2011 == ;;
 (setq lays (vla-get-layers
              (vla-get-activedocument (vlax-get-acad-object))
            )
 )
 (vlax-for x lays
   (if (wcmatch (setq Nme (vla-get-name x)) "C-*")
     (vla-put-name x (vl-string-subst "V-" "C-" Nme))
   )
 )
 (princ)
)

 

Regards,

 

Tharwat

Posted

I have forgotten that Multiple Selection method is allowed in Rename Command . :thumbsup:

Posted
I have forgotten that Multiple Selection method is allowed in Rename Command . :thumbsup:

Work smart, not hard.

Posted
Work smart, not hard.

 

Nice saying .

 

When being overwhelmed by lots of projects to hand over on time , there won't be time to spend on thinking than keep on working (sometimes) :lol:

Posted
Nice saying .

 

When being overwhelmed by lots of projects to hand over on time , there won't be time to spend on thinking than keep on working (sometimes) :lol:

Then maybe you should spend more time working and less time trolling the forums. ;)

Posted

There must a few seconds to get some fresh air , to be able to carry on and to keep the brain a live .:shock:

Posted
There must a few seconds to get some fresh air , to be able to carry on and to keep the brain a live .:shock:
Quick, step outside.
Posted

I am an idiot!!! thank you guys for being patient and supportive!!

Posted
I am an idiot!!! thank you guys for being patient and supportive!!

 

 

*US*

 

We'll whip you numpties into shape, one way or another! :P :rofl: LoL

 

^^ Just being sarcastic, of course. Please take no offense.

Posted

none taken.. i own a VW enthusiasts forum and we toss poo at each other all the time!! all in good fun!

Posted
none taken.. i own a VW enthusiasts forum and we toss poo at each other all the time!! all in good fun!

 

^^ Gold, that is. :rofl:

 

I'm glad you share the sense of humor; you *should* fit in nicely.

Posted

Man, this thread seems to have take a sh!77y direction and done down the toilet. :P

Posted
Man, this thread seems to have take a sh!77y direction and done down the toilet. :P

 

I hate it when things 'done down the toilet'. :rofl:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...