Page 1 of 4 1234 LastLast
Results 1 to 10 of 31

Thread: Match text strings by selecting

  1. #1
    Member
    Join Date
    2003-10
    Location
    Las Vegas
    Posts
    22
    Login to Give a bone
    0

    Exclamation Match text strings by selecting

    Does anyone know where I can find the lisp routine that when I pick a text string (example: Install blah blah) then I pick another text string and it will make the second text string match the first string word for word ?

  2. #2
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    You can try this code :
    Code:
    (defun c:InfectText (/ Ent TextSource SelSet Items Index EntDxf )
      (command "_.UNDO" "BEgin" )
      (if (setq Ent (entsel "Select the text infection source : " ) )
        (progn
          (if (= (cdr (assoc 0 (entget (car Ent ))) ) "TEXT" )
            (progn
              (setq TextSource (cdr (assoc 1 (entget (car Ent )))) )
              (prompt "\nSelect text to infect : " )
              (if (setq SelSet (ssget '((0 . "TEXT" ))) )
                (progn
                  (setq Items (sslength SelSet ) )
                  (setq Index -1 )
                  (repeat Items
                    (setq Index (1+ Index ) )
                    (setq EntDxf (entget (ssname SelSet Index ) ) )
                    (setq EntDxf (subst (cons 1 TextSource ) (assoc 1 EntDxf ) EntDxf ) )
                    (entmod EntDxf )
                  )
                  (princ (strcat (itoa Items ) " text objects changed to " TextSource " ! " ) )
                )
                (princ "No text selected ! " )
              )
            )
            (princ ".... you must select TEXT ! ")
          )
        )
        (princ "Miss, aim better ! ")
      )
      (command "_.UNDO" "End" )
      (princ )
    )
    : ) Happy Computing !

    kennet

  3. #3
    I could stop if I wanted to LanceMcHatton's Avatar
    Join Date
    2002-04
    Location
    Las Vegas, NV, USA
    Posts
    304
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Kennet,

    Did you write that code? I think I'll be replacing mine with yours and I'd like to give credit where it's due.
    Last edited by LanceMcHatton; 2005-08-30 at 03:32 PM.

  4. #4
    I could stop if I wanted to LanceMcHatton's Avatar
    Join Date
    2002-04
    Location
    Las Vegas, NV, USA
    Posts
    304
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Here's one that we use. It also only works on DTEXT entities but it's only good for a single use, whereas Kennet's lisp will pick a source and apply it to all selected entities.

    Code:
    ;  Description: Function to replace the value of a text entity with the
    ;  value of another text entity.
    ;
    ;  Originally written By: Robert P. Ehrman - 1/19/91
    ;  Modified by Lance McHatton for GCWallace, Inc. - March 24, 2004
    ;
    ;  Operation: The routine will ask you to pick two lines of text, then it
    ;			 will change the values of the second entity, but will not modify
    ;			 it in any other way, for instance, see below:
    ;
    ;			 Before the routine:
    ;			   text entity 1 is "L500" at 1,1 on "TH" with a value of "BACK OF CURB"
    ;			   text entity 2 is "L100" at 9,9 on "TS" with a value of "2900.25"
    ;			 After the routine:
    ;			   text entity 1 is "L500" at 1,1 on "TH" with a value of "BACK OF CURB"
    ;			   text entity 2 is "L100" at 9,9 on "TS" with a value of "BACK OF CURB"
    ;
    ;  Note: This lisp will only work on DTEXT entities.
    ;			 
    ;			 
    ;----------------------------------------------------------------------------
    (defun C:GCWCOPYTEXT (/ End Cmde Olderr Ename1 Ename2 Elist1 Elist2 Text1 Text2)
      (defun End (s)
    	(setvar "CMDECHO" Cmde)
    	(princ s)
    	(setq *error* olderr)
    	(princ)
      )
      (setq Cmde	 (getvar "CMDECHO")
    		Olderr   *error*
    		*error*  End)
      (while 1
    	(setq Elist1 '((0 . "BOGUS")))
    	(while (not (= (cdr (assoc 0 Elist1)) "TEXT"))
    	  (setq Ename1 (car (entsel "\nSelect FIRST text string. : ")))
    	  (setq Elist1 (entget Ename1)))
    	(setq Elist2 '((0 . "BOGUS")))
    	(while (not (= (cdr (assoc 0 Elist2)) "TEXT"))
    	  (setq Ename2 (car (entsel "\nSelect SECOND text string. : ")))
    	  (setq Elist2 (entget Ename2)))
    	(setq Text1 (cdr (assoc 1 Elist1)))
    	(setq Text2 (cdr (assoc 1 Elist2)))
    	(setq Elist1 (subst (cons 1 Text2) (assoc 1 Elist1) Elist1))
    	(setq Elist2 (subst (cons 1 Text1) (assoc 1 Elist2) Elist2))
    	(entmod Elist2)
    	)
      (End "\nFunction completed.")
      (princ)
    )

  5. #5
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Here is another one to consider.
    Code:
    ;**********************************************************************
    ; Original Program Name: C:CA
    ; Description:  Match text values in attributes or text strings. Pick
    ;               Source entity (Attribute or Text) then pick destination
    ;               entity, it will copy the text value from the source to
    ;               the destination.
    ; Date:         4-23-99
    ; Version:      1.00
    ; Author:       Micah Nerren (714) 556-4454
    ;**********************************************************************
    ; New Program Name: C:CopyText
    ; Overhauled 06-19-02 by John Uhden, Cadlantic
    ;       based on request by jducharme@reid-crowther.com
    ;       in the AutoCAD Customization Newsgroup.
    ; Note: Since there's almost nothing left of the original code,
    ;       this is donated as public domain, aka "Freeware"
    ;       R15+ only
    ;**********************************************************************
    (defun C:CopyText ( / *error* source text pick target ent layer)
      (vl-load-com)
      (if (not *acad*)(setq *acad* (vlax-get-acad-object)))
      (defun *error* (errmsg)
        (vla-EndUndoMark (vla-get-activedocument *acad*))
        (and
          errmsg
          (not (wcmatch (strcase errmsg) "*QUIT*,*CANCEL*"))
          (princ (strcat "\nERROR: " errmsg))
        )
        (princ)
      )
      (vla-StartUndoMark (vla-get-activedocument *acad*))
      (AND
        (setq source (car (nentsel"\nSelect Source Text/Attribute: ")))
        (setvar "errno" 0)
        (or
          (member (cdr (assoc 0 (setq source (entget source))))'("TEXT" "ATTRIB"))
          (prompt "\n  Must be either an Attribute or Text!")
        )
        (setq text (cdr (assoc 1 source)))
        (princ (strcat "\n  Source Value = " text))
        (while (/= (getvar "errno") 52)
          (and
            (setq pick (nentsel "\nSelect target Text/Attribute to change: "))
            (setq target (car pick))
            (setq ent    (entget target)
                  layer  (cdr (assoc 8 ent))
                  target (vlax-ename->vla-object target)
            )
            (or
              (= (length pick) 2)
              (prompt "\n  Target is nested in a Block or Xref")
            )
            (or
              (member (cdr (assoc 0 ent)) '("TEXT" "ATTRIB"))
              (prompt "\n  Must be either an Attribute or Text!")
            )
            (or
              (/= (logand 4 (cdr (assoc 70 (tblsearch "layer" layer)))) 4)
              (prompt (strcat "\n  Layer " layer " is locked"))
            )
            (or
              (/= (vla-get-textstring target) text)
              (prompt "\n  Text is the same.")
            )
            (and
              (not (vla-put-textstring target text))
              (/= (vla-get-textstring target) text)
              (princ "\n  Failed to modify target.")
            )
          )
        )
      )
      (*error* nil)
    )

  6. #6
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Quote Originally Posted by LMcHatton
    Kennet, Did you write that code?
    Yes ! Do whatever you like.

    : ) Happy Computing !

    kennet

  7. #7
    I could stop if I wanted to LanceMcHatton's Avatar
    Join Date
    2002-04
    Location
    Las Vegas, NV, USA
    Posts
    304
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Quote Originally Posted by ab2draft
    Here is another one to consider.
    Ok, now THAT one rocks! It does DTEXT and ATTRIBUTES! Back and forth!

    I wish all my favorite lisps would work out this way...getting better and better with every new post.

  8. #8
    Member
    Join Date
    2003-10
    Location
    Las Vegas
    Posts
    22
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Hey Thanks everyone. This is just what I was looking for.

  9. #9
    I could stop if I wanted to
    Join Date
    2015-09
    Posts
    420
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Hello To Everyone:

    Kennet, could your routine be modified to work with both "Text" and "Mtext" strings....???

    It would be very helpful if it could be accomplished....!!!

    Thank you for any assistance.

  10. #10
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Match text strings by selecting

    Quote Originally Posted by vferrara
    Hello To Everyone:

    Kennet, could your routine be modified to work with both "Text" and "Mtext" strings....???

    It would be very helpful if it could be accomplished....!!!

    Thank you for any assistance.
    Change the line
    (if (setq SelSet (ssget '((0 . "TEXT" ))) )
    to
    (if (setq SelSet (ssget '((0 . "TEXT,MTEXT" ))) )

    But it will NOT work at all MTEXT

    : ) Happy Computing !

    kennet

Page 1 of 4 1234 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 2014-03-02, 01:06 AM
  2. Linking text strings
    By DaleSmith in forum Revit Architecture - General
    Replies: 2
    Last Post: 2011-11-25, 09:26 AM
  3. Text strings in Dimensions
    By DaveP in forum Revit Architecture - Wish List
    Replies: 3
    Last Post: 2006-06-26, 12:34 AM
  4. Match Text string by selecting
    By lapace in forum AutoCAD General
    Replies: 3
    Last Post: 2005-10-18, 03:34 PM
  5. formating text strings
    By rwbaker in forum VBA/COM Interop
    Replies: 6
    Last Post: 2005-09-20, 06:02 PM

Posting Permissions

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