+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Question Routine to add modified text below existing text (copy/replace?)...

    Registered forum members do not see this ad.

    Hi guys,

    Im not sure the best way to explain what I am looking for – but I would like to have a LISP routine that would copy and replace text.

    I am a steel detailer and we recently switched from one AutoCAD add-on package to another. The original software package had the ability to copy text below itself, then replace the copied text with new text (same size, style… and copied it a standard distance below the existing text). This feature is very handy when labeling dimensions.

    Please see attached image for examples…

    The distance that the new text is copied below the existing text would be proportional to the text height (style).

    Thanks so much for any help.

    Ps... i thought it would also be worth noting that it would be pre-defined text getting added below the existing text. So there could be a range of commands... ie. command 'TYP' would add the text "TYP", 'EQ' would add "= =", etc...

    Copied Text Example.jpg
    Last edited by lamensterms; 15th Jun 2011 at 01:09 am.

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,456

    Default

    How about using DDEdit on the Dimension and then <>\XTYP or <>\XREF
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Default

    Hi Lee, thanks for the reply..

    can you please elaborate on that response? what is the function of <>\X? and how can i use it?

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,456

    Default

    When you DDEdit a Dimension you are modifying the Text Override Content of the Dimension.

    The <> represents the dimension measurement in this override string, and \X will place any text following it underneath the dimension line.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  5. #5
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Cool

    Oh wow, that’s great. Thanks so much Lee, for your help and your quick response.

    I understand that the ‘<>\X’ input needs to be written into a routine – rather than simply adding it in autoCAD? (otherwise the ‘<>’ appears as part of the dimension text?)

    I have actually just found a routine that will accomplish exactly what I need – using the same method you describe.

    Code:
    (Defun c:fieldverify ()
     (setq newdim (entsel "\n Select Dimension to Add FIELD VERIFY to:"))
     (setq newdimvalue "<>\\X FIELD VERIFY")
     (command "dimedit" "n" newdimvalue newdim "")
     (princ)
     )
    http://www.archidigm.com/lounge/auto...dimensions.htm

    Thanks again for you help.

    Cheers.

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,456

    Default

    The text override could be typed manually or used in a program.

    A few examples:

    Code:
    (defun c:test1 ( / e )
      (if 
        (and
          (setq e (car (entsel "\nSelect Dimension: ")))
          (wcmatch (cdr (assoc 0 (setq e (entget e)))) "*DIMENSION")
        )
        (entmod (subst (cons 1 "<>\\XTYP") (assoc 1 e) e))
      )
      (princ)
    )
    Code:
    (defun c:test2 ( / ss i e )
      (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
        (repeat (setq i (sslength ss))
          (setq e (entget (ssname ss (setq i (1- i)))))
          (entmod (subst (cons 1 "<>\\XTYP") (assoc 1 e) e))
        )
      )
      (princ)
    )
    There may be typo's as I've just typed that code from my mobile.
    Last edited by Lee Mac; 15th Jun 2011 at 02:34 pm.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Default

    Thats great, thanks again for all this help Lee.

    will any of these routines work on dtext or mtext? i would mainly use these routines to run on dimensions, but would also like to use them on normal text.

    thanks again for taking the time mate.

  8. #8
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Default

    Also... is it possible to have multiple lines of notes added below a dimension?

    like this...

    Copied Text Example 2.jpg

    thanks again.

  9. #9
    Senior Member
    Computer Details
    VVA's Computer Details
    Operating System:
    Windows 7
    CPU:
    Intel Core i5-2400
    RAM:
    8 Gb
    Graphics:
    Nvidia Quadro 600
    Primary Storage:
    Seagate 500 GB + WD 750 GB
    Monitor:
    Philips 27"
    Using
    AutoCAD 2013
    Join Date
    Dec 2006
    Location
    Minsk, Belarus
    Posts
    447

    Default

    Code:
    (defun c:test2 ( / ss i e )
      (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
        (repeat (setq i (sslength ss))
          (setq e (entget (ssname ss (setq i (1- i)))))
          (entmod (subst (cons 1 "<>\\XREF\\PTYP") (assoc 1 e) e))
        )
      )
      (princ)
    )

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,456

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by lamensterms View Post
    will any of these routines work on dtext or mtext? i would mainly use these routines to run on dimensions, but would also like to use them on normal text.
    You could use the "\\P" string to insert a new line to the end of an MText string, however, for DText you would need to create a new DText object at a distance below the original calculated from the text height of the selected DText and a Line spacing factor (such as 1.5).
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. Lisp routine to measure line and add length to existing text
    By emwhite in forum AutoLISP, Visual LISP & DCL
    Replies: 26
    Last Post: 23rd Nov 2016, 11:31 am
  2. Replies: 10
    Last Post: 5th Apr 2011, 04:43 pm
  3. replace text within text
    By shoyur in forum AutoCAD General
    Replies: 3
    Last Post: 21st Mar 2011, 06:24 pm
  4. Replace text with Blocks
    By marcs in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 1
    Last Post: 3rd Dec 2009, 06:51 am
  5. Replace Text
    By viriato79 in forum AutoCAD General
    Replies: 5
    Last Post: 5th Aug 2009, 07:20 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