+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22
  1. #1
    Forum Newbie
    Using
    Map 3D 2011
    Join Date
    May 2012
    Posts
    7

    Default Converting a text string to a known block

    Registered forum members do not see this ad.

    Hello,

    question for ya all out there.. so, in a drawing, i have several text strings, 's', that i would like to change to a known block... is this able to be done? there are over 3000 's' in the drawing, hoping to change them all to the same block. let me know if this can be done. thanks

    colby

  2. #2
    Senior Member
    Using
    AutoCAD 2012
    Join Date
    Jun 2012
    Posts
    350

    Default

    Hi, Colby,

    Yes, this type of replacement is certainly possible, though it will likely have to be via AutoLISP. Somebody has probably already done smth like this. The easiest thing to program would be for inserting the block at each insertion point of the text at a scale factor of 1, rotation 0, erasing the ‘s’ text afterward. Would that be sufficient? If not, tell us what else you would need.

  3. #3
    Forum Newbie
    Using
    Map 3D 2011
    Join Date
    May 2012
    Posts
    7

    Default

    that is exactly what i need, and i have been scouring the net looking for a lisp routine that would work, or i could edit slgihtly, since i am not a lisp expert there is noway i could make one from scratch.

  4. #4
    Senior Member
    Using
    AutoCAD 2012
    Join Date
    Jun 2012
    Posts
    350

    Default

    OK. Just to make sure I know what I’m dealing with before I get started, please enter the LISP code below on the command line (you can simply copy and paste), select an ‘s’, then post the full result here. It will give the AutoLISP entity data list (a bunch of stuff in parentheses) of the selected item regardless of what it is.

    Code:
     
    (setq E (car (entsel)) N E L (entget E))
    Last edited by neophoible; 17th Aug 2012 at 05:21 pm. Reason: added code tags to short code snippets

  5. #5
    Forum Newbie
    Using
    Map 3D 2011
    Join Date
    May 2012
    Posts
    7

    Default

    here is what i got in return

    ((-1 . <Entity name: 7ffff1de860>) (0 . "TEXT") (330 . <Entity
    name: 7ffff7119f0>) (5 . "613E") (100 . "AcDbEntity") (67 . 0) (410 . "Model")
    (8 . "Pole") (100 . "AcDbText") (10 638134.0 5.87584e+006 0.0) (40 . 15.7653)
    (1 . "s") (50 . 4.74066) (41 . 1.0) (51 . 0.0) (7 . "Font10800") (71 . 0) (72 .
    1) (11 638142.0 5.87584e+006 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 2))

    thanks a lot!!

    colby

  6. #6
    Senior Member
    Using
    AutoCAD 2012
    Join Date
    Jun 2012
    Posts
    350

    Default

    OK. This looks good. It may take me a few minutes to sort this out. In the meantime, be sure to do a backup SAVE of your drawing just in case! This is always true, of course. And you will want to test it with just a few instances of ‘s’ in a test drawing first, just to make sure it works. So you can go ahead and set up a TEST dwg if you haven’t already. The 3000 shouldn’t take too long, but long enough.

  7. #7
    Super Member JPlanera's Avatar
    Computer Details
    JPlanera's Computer Details
    Operating System:
    Win7 x64
    Computer:
    Dell T7400
    CPU:
    (4) Intel Xeon CPU X5272 @ 3.4GHz
    RAM:
    8G
    Graphics:
    NVIDIA Quadro FX 570 & RADEON X6000
    Primary Storage:
    80G main
    Secondary Storage:
    1TB ext
    Monitor:
    (3) DELL 21" wide
    Using
    Mechanical 2012
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    526

    Default

    Wouldnt QSELECT work? Once all the 's' are selected, they can be manipulated anyway you want..

    Edit: i take that back... nevermind upon re reading the OP question...
    You might be an engineer, if you tell people that time travel does not exist..... and then 5 minutes later explain how you would build a time machine

    Engineers aren't boring people, we just get excited over boring things.

  8. #8
    Senior Member
    Using
    AutoCAD 2012
    Join Date
    Jun 2012
    Posts
    350

    Default

    Well, I started on it and thought I just about had it, then manged to lock up my machine! If someone else doesn't jump in, I'll plan to tackle this tomorrow. One way or another, I believe help is on its way. Just hang in there.

  9. #9
    Senior Member
    Using
    AutoCAD 2012
    Join Date
    Jun 2012
    Posts
    350

    Default

    Well, I decided to keep going since I felt so close. It's kinda down n dirty but does the trick for the specific situation. I tested it with BORDER, so you will need to put your block's name in place of that. TBR was for Text-Block-Replace.

    Code:
     
    (defun C:TBR (
      / Text_set    ;               
        Set_index   ; 
        Insert_pt    
        BlockName        
        New_elist   ;
                 )
    ; This assumes there is at least one TEXT object with value "s" AND that the
    ;  BLOCk name is already defined in the drawing        
      (prompt "\nSelecting text to replace...")
    ; If your text is other than "s", then replace the "s" with yours
      (setq Text_set (ssget "X" '(
        (-4 . "<AND")
          (0 . "TEXT") (1 . "s")
        (-4 . "AND>")
      )              )           )
      (setq Set_index (sslength Text_set))
    ; Need to put your block name in the quotes!
      (setq BlockName "BORDER")
      (command "Select" Text_set "")
      (prompt (strcat
        "\nReplacing " (rtos Set_index 2 0)
        " occurrence(s) of TEXT:\"s\"" 
        " with BLOCK:\"" BlockName "\"..."
      )       )
      (if (not (>= Set_index 1)) (exit))
      (repeat Set_index 
        (setq Set_index (1- Set_index))
        (setq New_elist (entget (ssname Text_set Set_index)))
        (setq Insert_pt (cdr (assoc 11 New_elist)))
        (command "._INSERT" BlockName "S" "" "R" "" Insert_pt)
      )
      (prompt "\nErasing the text...")
      (Command "._ERASE" Text_set "")
      (prompt "Done.")
      (princ)
    )   
    (C:TBR)
    Last edited by neophoible; 17th Aug 2012 at 04:27 pm. Reason: accidentally used the insertion 10 code instead of 11

  10. #10
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    Registered forum members do not see this ad.

    Ia a check for S & s (0 . "TEXT") (1 . "s") required remember there are 52 characters in the alphabet.
    A man who never made mistakes never made anything

Similar Threads

  1. Block Text Problem when converting from Paper Space .dwg to .pdf
    By icemate09 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 5
    Last Post: 13th Jul 2012, 07:00 pm
  2. How do I change text edit to start at the end of a string of text?
    By uuoo10levi in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 4
    Last Post: 26th Jun 2012, 10:18 pm
  3. Converting a List into a String
    By Silvercloak in forum AutoLISP, Visual LISP & DCL
    Replies: 16
    Last Post: 23rd Mar 2012, 03:00 am
  4. How to add a string to a text.
    By LISP2LEARN in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 3rd Jun 2011, 12:00 am
  5. Get Value of text string from a Block
    By TMORRIS in forum AutoLISP, Visual LISP & DCL
    Replies: 16
    Last Post: 19th May 2011, 08:42 pm

Bookmarks

Posting Permissions

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