See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: Take existing drawings and find all "|" and replace with "1/4"

  1. #1
    I could stop if I wanted to sschwartz85916's Avatar
    Join Date
    2005-04
    Location
    Oakland County, Michigan
    Posts
    424
    Login to Give a bone
    0

    Red face Take existing drawings and find all "|" and replace with "1/4"

    Question:
    We are changing the standard font from freehand.shx to simplex.shx in our office. The problem is, that there are a certain number of keyboard "symbols" in the freehand font _ | { \ } [ ] < > ~ ' ; that when typed in, make up a number of fractions, and a few other symbols. SOOO, when we use simplex, the fraction 1/4 converts to a | . (Kind of difficult to call out a conduit size as that...)

    I have tried find and replace, and quickselect, etc. It will not read the 'symbol' properly. Any ideas of a way to take existing drawings and find all "|" and replace with "1/4".

    I have attached the font we are converting from...
    Attached Files Attached Files

  2. #2
    Login to Give a bone
    2

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    I tried using AutoCAD's Find with the FreeHand.shx font and it worked ok on our system. Here is a function that I wrote to be used in programs, but it can be run on the command line using the following syntax:
    (FindReplaceAll "|" "1/4")
    Use it with care, because it does exactly what it's named.

    Terry Cadd

    Code:
    ;-------------------------------------------------------------------------------
    ; FindReplaceAll - Changes Text, Mtext, Dimensions and Attribute Block entities
    ; that have a Find$ string with a Replace$ string.
    ; Arguments: 2
    ;   Find$ = Phrase string to find
    ;   Replace$ = Phrase to replace it with
    ; Syntax: (FindReplaceAll "|" "1/4")
    ; Returns: Updates Text, Mtext, Dimension and Attribute Block entities
    ;-------------------------------------------------------------------------------
    (defun FindReplaceAll (Find$ Replace$ / BlkEntList@ BlkEntName^ BlkEntType$ Cnt#
      DimEntList@ DimEntName^ DimEntType$ EntList@ EntName^ EntType$ FindReplace:
      Mid$ Mid2$ NewText$ Num# Replace$ SS& Text$)
      ;-----------------------------------------------------------------------------
      ; FindReplace: - Returns Str$ with Find$ changed to Replace$
      ; Arguments: 3
      ;   Str$ = Text string
      ;   Find$ = Phrase string to find
      ;   Replace$ = Phrase to replace Find$ with
      ; Returns: Returns Str$ with Find$ changed to Replace$
      ;-----------------------------------------------------------------------------
      (defun FindReplace: (Str$ Find$ Replace$ / Cnt# FindLen# Loop Mid$ NewStr$ ReplaceLen#)
        (setq Loop t Cnt# 1 NewStr$ Str$ FindLen# (strlen Find$) ReplaceLen# (strlen Replace$))
        (while Loop
          (setq Mid$ (substr NewStr$ Cnt# FindLen#))
          (if (= Mid$ Find$)
            (setq NewStr$ (strcat (substr NewStr$ 1 (1- Cnt#)) Replace$ (substr NewStr$ (+ Cnt# FindLen#)))
                  Cnt# (+ Cnt# ReplaceLen#)
            );setq
            (setq Cnt# (1+ Cnt#))
          );if
          (if (= Mid$ "") (setq Loop nil))
        );while
        NewStr$
      );defun FindReplace:
      ;-----------------------------------------------------------------------------
      ; Start of Main function
      ;-----------------------------------------------------------------------------
      (if (and (= (type Find$) 'STR)(= (type Replace$) 'STR)(/= Find$ ""))
        (progn
          (if (setq SS& (ssget "x" (list '(-4 . "<AND")'(-4 . "<OR")'(0 . "TEXT")'(0 . "MTEXT")'(0 . "DIMENSION")'(0 . "INSERT")'(-4 . "OR>")(cons 410 (getvar "CTAB"))'(-4 . "AND>"))))
            (progn
              (command "UNDO" "BEGIN")
              (setq Cnt# 0)
              (repeat (sslength SS&)
                (setq EntName^ (ssname SS& Cnt#)
                      EntList@ (entget EntName^)
                      EntType$ (cdr (assoc 0 EntList@))
                      Text$ (cdr (assoc 1 EntList@))
                );setq
                (if (= EntType$ "INSERT")
                  (if (assoc 66 EntList@)
                    (progn
                      (while (/= (cdr (assoc 0 EntList@)) "SEQEND")
                        (setq EntList@ (entget EntName^))
                        (if (= (cdr (assoc 0 EntList@)) "ATTRIB")
                          (progn
                            (setq Text$ (cdr (assoc 1 EntList@)))
                            (if (wcmatch Text$ (strcat "*" Find$ "*"))
                              (progn
                                (setq ReplaceWith$ (FindReplace: Text$ Find$ Replace$))
                                (entmod (subst (cons 1 ReplaceWith$) (assoc 1 EntList@) EntList@))
                                (entupd EntName^)
                              );progn
                            );if
                          );progn
                        );if
                        (setq EntName^ (entnext EntName^))
                      );while
                    );progn
                  );if
                  (if (wcmatch Text$ (strcat "*" Find$ "*"))
                    (progn
                      (setq ReplaceWith$ (FindReplace: Text$ Find$ Replace$))
                      (entmod (subst (cons 1 ReplaceWith$) (assoc 1 EntList@) EntList@))
                      (entupd EntName^)
                    );progn
                  );if
                );if
                (setq Cnt# (1+ Cnt#))
              );repeat
              (command "UNDO" "END")
            );progn
          );if
        );progn
      );if
      (princ)
    );defun FindReplaceAll
    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Last edited by Terry Cadd; 2006-07-17 at 08:38 PM. Reason: [CODE] tags added.

  3. #3
    I could stop if I wanted to sschwartz85916's Avatar
    Join Date
    2005-04
    Location
    Oakland County, Michigan
    Posts
    424
    Login to Give a bone
    0

    Talking Re: Take existing drawings and find all "|" and replace with "1/4"

    Wow! I can work with this... thank you so much! Great

  4. #4
    Member
    Join Date
    2004-02
    Location
    Lincoln, NE
    Posts
    31
    Login to Give a bone
    0

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    I'm trying to do a similar task with a different font. I can get the command line version to work, but when I try to run it numerous times in a single lisp routine I get an unknown command error. How do you use this "in a program"?

    Here's exactly what I'm trying to do:
    convert "%%11" to "1/16"
    convert "%%12" to "1/8"
    convert "%%13" to "3/16"
    ... and so on to 7/8

    It would also be helpful to know the best way to load findreplaceall so this routine can call it.

    Thanks,
    BATx2

  5. #5
    I could stop if I wanted to sschwartz85916's Avatar
    Join Date
    2005-04
    Location
    Oakland County, Michigan
    Posts
    424
    Login to Give a bone
    0

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    Quote Originally Posted by BATx2
    I'm trying to do a similar task with a different font. I can get the command line version to work, but when I try to run it numerous times in a single lisp routine I get an unknown command error. How do you use this "in a program"?

    Here's exactly what I'm trying to do:
    convert "%%11" to "1/16"
    convert "%%12" to "1/8"
    convert "%%13" to "3/16"
    ... and so on to 7/8

    It would also be helpful to know the best way to load findreplaceall so this routine can call it.

    Thanks,
    BATx2
    If you have the lisp routine, you need to appload it. (I suggest adding it to your startup suite). I am not 100% sure, but you may need to make one lisp for each find and replace.

  6. #6
    Login to Give a bone
    0

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    (load "FindReplaceAll");or place it in another startup loading file such as AcadDoc.lsp.

    Create a similar function as follows that you will run on those drawings.
    Load the new function from the command line i.e. (load "Replace"),
    or better yet place it in another startup loading file such as AcadDoc.lsp.
    Using APPLOAD is still another possibility to load these files.

    Code:
    (defun c:Replace ()
      (FindReplaceAll "%%11" "1/16")
      (FindReplaceAll "%%12" "1/8")
      (FindReplaceAll "%%13" "3/16")
      ;etc.
      (princ)
    );defun
    Last edited by Terry Cadd; 2006-10-30 at 11:09 PM. Reason: Added code tag.

  7. #7
    Member
    Join Date
    2000-11
    Posts
    6
    Login to Give a bone
    0

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    Terry,

    This works great unless you are (or in this case "I am") trying to replace path statements. It then thinks you need another double-quote mark and another end parenthesis, after which it simply fails.

    (findreplaceall "\\server\path\path\dir\" "N:\dir")

    ...for example.

    Merle

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,541
    Login to Give a bone
    0

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    Quote Originally Posted by Merle.Hall
    Terry,

    This works great unless you are (or in this case "I am") trying to replace path statements. It then thinks you need another double-quote mark and another end parenthesis, after which it simply fails.

    (findreplaceall "\\server\path\path\dir\" "N:\dir")

    ...for example.

    Merle
    Since this is in AutoLISP, add another slash "\" next to your current slash "\".
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #9
    Member
    Join Date
    2000-11
    Posts
    6
    Login to Give a bone
    0

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    I knew that! But I figured it would look for the exact string, not an interpreted one. Should have tried it anyway.

    Thanks!

    Merle

  10. #10
    Woo! Hoo! my 1st post
    Join Date
    2009-09
    Posts
    1
    Login to Give a bone
    0

    Default Re: Take existing drawings and find all "|" and replace with "1/4"

    Hi! Can you advice how to add multiline attributes to the processing by application (it is working only with single line attribute). Thank you

Similar Threads

  1. 2013: Find and Replace is NOT "Replacing" but adding to it??
    By tedg in forum AutoCAD Annotation
    Replies: 26
    Last Post: 2013-09-19, 04:11 AM
  2. Replies: 0
    Last Post: 2012-06-06, 11:54 AM
  3. Replies: 1
    Last Post: 2009-09-10, 10:58 AM
  4. ENTIDADES EN ALIGNMENT COMO "FIXED", "FLOTING" y "FREE"
    By cadia in forum Español - AutoCAD Civil 3D
    Replies: 1
    Last Post: 2009-02-01, 04:21 AM
  5. Change Find and Replace "Zoom To" height
    By JeremiahM in forum AutoCAD General
    Replies: 2
    Last Post: 2007-06-04, 03:09 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
  •