Results 1 to 7 of 7

Thread: Delete Duplicate Text in the same object

  1. #1
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Delete Duplicate Text in the same object

    Does anyone know what I can use to select a piece of text and have it pick out duplicate words and delete the one I choose

    Here is an example

    44+44 44+44 12" MAPLE 36 36'

    I would like to delete the one of the 44+44's and the 36 without the '

    There are about 200 to 300 text that are similar to the example in a drawing I am working with.

    Any help would be appreciated

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Delete Duplicate Text in the same object

    Quote Originally Posted by ccowgill
    Does anyone know what I can use to select a piece of text and have it pick out duplicate words and delete the one I choose

    Here is an example

    44+44 44+44 12" MAPLE 36 36'

    I would like to delete the one of the 44+44's and the 36 without the '

    There are about 200 to 300 text that are similar to the example in a drawing I am working with.

    Any help would be appreciated
    Hi ccowgill

    Let play with this

    Thank you

    f.

    Code:
    (setq new_text "44+44 12\" MAPLE 36'")
    ;;or:
    ;;(setq new_text (getstring T "\nEnter new string : \n"))
    (setq ss
    (ssget "_X" '((0 . "TEXT")(1 . "*44+44*,*36'"))) i -1)
    (while (setq en (ssname ss (setq i (1+ i))))
      (setq elist (entget en))
    	(entmod (subst (cons 1 new_text)(assoc 1 elist) elist))
    	(entupd en)
    	)

  3. #3
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Delete Duplicate Text in the same object

    I think better yet:

    Better yet:

    Code:
    (setq ss
    (ssget "_X" '((0 . "TEXT")(1 . "*##+##,*##'"))) i -1)
    (while (setq en (ssname ss (setq i (1+ i))))
      (setq elist (entget en))
      (setq str (cdr (assoc 1 elist))
    	str (substr str 7 (strlen str))
    	str (substr str 1 (- (strlen str) 4))
    	str (strcat str "'"))
    	(entmod (subst (cons 1 str)(assoc 1 elist) elist))
    	(entupd en)
    	)

  4. #4
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Delete Duplicate Text in the same object

    Quote Originally Posted by fixo
    I think better yet:

    Better yet:

    Code:
    (setq ss
    (ssget "_X" '((0 . "TEXT")(1 . "*##+##,*##'"))) i -1)
    (while (setq en (ssname ss (setq i (1+ i))))
      (setq elist (entget en))
      (setq str (cdr (assoc 1 elist))
    	str (substr str 7 (strlen str))
    	str (substr str 1 (- (strlen str) 4))
    	str (strcat str "'"))
    	(entmod (subst (cons 1 str)(assoc 1 elist) elist))
    	(entupd en)
    	)
    That is a great start, the modification I know how to do is remove the "_X" to select each piece of text that is affected (about 75% of the total) The next problem is to get it to recognize that not all the notes are ##+##, some are #+## and I would like to get rid of the first ##' which also has a RT or LT attached
    Ex.

    1+08 1+08 TELE. CBL MKR 20'RT 19'
    17+00 17+00 10" STUMP 43'RT 43'

    In other words, remove the text in red

  5. #5
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Delete Duplicate Text in the same object

    Hi ccjwgill

    Sorry no time to test it:

    Code:
    (setq ss
    	 (ssget "_X" '((0 . "TEXT") (1 . "*##+##,*##'")))
          i	 -1
    )
    (while (setq en (ssname ss (setq i (1+ i))))
      (setq elist (entget en))
      (setq	str (cdr (assoc 1 elist))
    	str (substr str 7 (strlen str))
    	str (substr str 1 (- (strlen str) 4))
    	str (strcat str "'")
      )
      (entmod (subst (cons 1 str) (assoc 1 elist) elist))
      (entupd en)
    )
    ;;	Ater executing of first code part you can try
    ;;	following one:
    (setq ss1
    	  (ssget "_X" '((0 . "TEXT") (1 . "*#'@* *#'")))
          i	  -1
    )
    (while (setq en (ssname ss1 (setq i (1+ i))))
      (setq elist (entget en))
      (setq	str	(cdr (assoc 1 elist))
    	start	(+ 2 (vl-string-position 32 str))
    	str	(substr str start (strlen str))
    	start	(vl-string-position 39 str)
    	del_str	(substr str (- start 2) 6)
    	str	(vl-string-subst (chr 32) del_str str)
      )
      (entmod (subst (cons 1 str) (assoc 1 elist) elist))
      (entupd en)
    )
    Thank you

    f.

  6. #6
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Delete Duplicate Text in the same object

    Code:
    (defun c:dud ()
    (setq ss1
    	  (ssget  '((0 . "TEXT") (1 . "*#'@* *#'")))
          i	  -1
    )
    (while (setq en (ssname ss1 (setq i (1+ i))))
      (setq elist (entget en))
      (setq	str	(cdr (assoc 1 elist))
    	start	(+ 2 (vl-string-position 32 str))
    	str	(substr str start (strlen str))
    	start	(vl-string-position 39 str)
    	del_str	(substr str (- start 2) 6)
    	str	(vl-string-subst (chr 32) del_str str)
      )
      (entmod (subst (cons 1 str) (assoc 1 elist) elist))
      (entupd en)
    )
    )
    Thanks for the help, the second code worked for what I needed.
    Last edited by ccowgill; 2005-11-21 at 11:17 PM. Reason: fix code tags

  7. #7
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Delete Duplicate Text in the same object

    Thanks for the help, the second code worked for what I needed.

    You're welcome.
    Glad to hear its working

    F.

Similar Threads

  1. Can't delete object with delete button
    By gtx in forum AutoCAD General
    Replies: 5
    Last Post: 2015-02-02, 01:52 AM
  2. Merge does not delete duplicate geometry
    By kurteh in forum NavisWorks - General
    Replies: 0
    Last Post: 2011-10-19, 06:37 PM
  3. Delete duplicate entities
    By daniel.144778 in forum AutoCAD General
    Replies: 4
    Last Post: 2008-05-30, 04:10 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
  •