Results 1 to 2 of 2

Thread: Find text, change layer

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2015-08
    Posts
    1
    Login to Give a bone
    0

    Default Find text, change layer

    Hi All,

    I'm new to lisps and the syntax is a little confusing to me so I'm having a little trouble. I have a text layer that contains around 500 text and mtext strings. I need to search for a string within the text and if it matches, change the layer. Here's an example of the logic:

    find "HW"
    change object layer to "HW-TXT"

    find "WFI"
    change object layer to "WFI-TXT"

    find "CHWS"
    change object layer to "CHWS-TXT"
    ect...

    If possible, it would be nice to be able to view the object before the layer is changed similar to how you can view all of the text when you use find and replace before replacing it but it's not absolutely necessary.

    Thanks in advance

  2. #2
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Find text, change layer

    Code:
    (defun C:TextLayer ()
     (command "layer" "m" "HW-TXT" "m" "WFI-TXT" "m" "CHWS-TXT" "u" "*" "")
     (and
      (setq ssSelections (ssget "x" (list (cons 0 "*text"))))
      (setq	lstObjects   (SelectionSetToList ssSelections))
      (mapcar '(lambda (X)(changetextlayer X "*HW*"   "HW-TXT"  )) lstObjects)
      (mapcar '(lambda (X)(changetextlayer X "*WFI*"  "WFI-TXT" )) lstObjects)
      (mapcar '(lambda (X)(changetextlayer X "*CHWS*" "CHWS-TXT")) lstObjects)
     )
    )
    
    (defun ChangeTextlayer (objItem strWCMatch strLayer)
     (if (wcmatch (strcase (vla-get-textstring objItem)) (strcase strWCMatch))
      (vla-put-layer objItem strLayer)
     )
    )
    
    (defun SelectionSetToList (ssSelections / entSelection intCount lstObjects objSelection )
     (repeat (setq intCount (sslength ssSelections))
      (setq intCount (1- intCount))
      (setq entSelection (ssname ssSelections intCount))
      (setq objSelection (vlax-ename->vla-object entSelection))
      (setq lstObjects   (cons objSelection lstObjects))
     )
     (reverse lstObjects)
    )
    
    (vl-load-com)
    Attached Files Attached Files
    AutomateCAD

Similar Threads

  1. Replies: 5
    Last Post: 2008-11-27, 06:38 AM
  2. Replies: 6
    Last Post: 2007-05-30, 05:45 PM
  3. Replies: 7
    Last Post: 2006-10-23, 04:18 AM
  4. Windows XP - Make Built-in Windows Search find text in text files with Unknown Extensions
    By Mike.Perry in forum Operating Systems
    Replies: 0
    Last Post: 2005-07-17, 11:53 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •