+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 8.1 Enterprise; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2016
    Join Date
    Feb 2009
    Location
    Kansas City, MO
    Posts
    438

    Default Remove Character From MText

    Registered forum members do not see this ad.

    I am trying to remove a hyphen from mtext. The hyphen will not always be in the same location. This is an example of what I am trying to do:

    12-1/4" to 12 1/4"

    Could someone point me in the right direction of how to achieve this please? Thank you.
    Kyle

    AutoCad MEP 2016; Fabrication CADmep 2016; Navisworks Manage 2016; Revit 2016
    HP Elitebook 8760w; Windows 8.1 Enterprise; 64-bit; 16GB RAM; NVIDIA Quadro 4000M

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,539

    Default

    • Prompt user to select MText (entsel)
    • Retrieve the MText DXF data (entget)
    • Retrieve the MText content (DXF group 1: cdr / assoc)
    • Retrieve the position of the hyphen in the string if present (vl-string-search / vl-string-position)
    • Remove the hyphen from the string (substr)*
    • Update the DXF data with the new content (subst)
    • Modify the MText entity (entmod)
    *There are several alternative methods to approach this step:
    • Substitute the hyphen for an empty string (vl-string-subst)
    Or:
    • Convert the string to a list of ASCII characters (vl-string->list)
    • Remove the hyphen character (vl-remove)
    • Convert the list of ASCII characters back to a string (vl-list->string)
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  3. #3
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 8.1 Enterprise; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2016
    Join Date
    Feb 2009
    Location
    Kansas City, MO
    Posts
    438

    Default

    Thank you Lee Mac. I will give these a shot and post an update later.
    Kyle

    AutoCad MEP 2016; Fabrication CADmep 2016; Navisworks Manage 2016; Revit 2016
    HP Elitebook 8760w; Windows 8.1 Enterprise; 64-bit; 16GB RAM; NVIDIA Quadro 4000M

  4. #4
    Senior Member ksperopoulos's Avatar
    Computer Details
    ksperopoulos's Computer Details
    Operating System:
    Windows 8.1 Enterprise; 64-bit
    Computer:
    HP Elitebook 8760w
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro 4000M
    Using
    AutoCAD 2016
    Join Date
    Feb 2009
    Location
    Kansas City, MO
    Posts
    438

    Default

    Registered forum members do not see this ad.

    Lee Mac - This seems to work. Thank you for the help!

    Code:
    (defun c:testsize ( / obj lay sz1 sz2)
    (vl-load-com)
    (setq obj (entget (car (entsel "\nSelect Object"))))
    (setq lay (cdr (assoc 8 obj)))
    (setq sz1 (cdr (nth 9 obj)))
    (setq sz2 (vl-string-subst " " "-" sz1))
    (command "clayer" (strcat lay "-SIZE"))
    (command "mleader" pause pause (strcat sz2 "\""))
    (princ)
    )
    Kyle

    AutoCad MEP 2016; Fabrication CADmep 2016; Navisworks Manage 2016; Revit 2016
    HP Elitebook 8760w; Windows 8.1 Enterprise; 64-bit; 16GB RAM; NVIDIA Quadro 4000M

Similar Threads

  1. A lisp remove the last character of a text.
    By Tunnelrat in forum AutoLISP, Visual LISP & DCL
    Replies: 33
    Last Post: 15th Feb 2013, 07:23 pm
  2. Remove Duplicates (remove both the duplicate and the original)
    By lasersocks in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 26th Oct 2011, 12:59 am
  3. Global Mtext character change
    By TroutKing in forum AutoCAD General
    Replies: 2
    Last Post: 27th May 2008, 03:51 pm
  4. How to remove corner radiuses in views; to remove confusing double lines in layout
    By nbaryosef in forum AutoCAD Drawing Management & Output
    Replies: 27
    Last Post: 17th Feb 2008, 12:06 am
  5. Can Lisp use mtext to make multi string mtext editor?
    By muck in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 18th Dec 2006, 03:22 am

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