Results 1 to 9 of 9

Thread: Modify Text

  1. #1
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Modify Text

    Hi,
    I have not been able to find any help on this. I have found similar codes but nothing that does what I want.


    I need to be able to change the following mtext:

    "-1,624.000" to "-1,6-24.000"

    at the moment the "-" symbol will always be entered as the 5th Character

    would really appreciate some help on this.

    I want to be able to select multiple mtext at once and then let a "foreach" or something similar run the neccessary code over it.

    thanks

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Modify Text

    What does the text represent? Is the placement of "-" in relation to the decimal point or will it always be entered as the 5th Character?

  3. #3
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Re: Modify Text

    it represents chainage.

    But actually that is a goode point. it will always be 3 places before the decimal point and not always in the 5 th position.
    It is just in this case that it is in the 5th posiiton.

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify Text

    Give this a try:
    Code:
    (vl-load-com)
    
    (defun c:FOO (/ *error* acDoc s i)
    
      (defun *error* (msg)
        (if acDoc
          (vla-endundomark acDoc)
        )
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (if (ssget "_:L"
                 '((0 . "MTEXT")
                   (1 . "*,*.*")
                   (-4 . "<NOT")
                   (1 . "*-##.*")
                   (-4 . "NOT>")
                  )
          )
        (progn
          (vla-startundomark
            (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
          )
          (vlax-for x (vla-get-activeselectionset acDoc)
            (vla-put-textstring
              x
              (strcat (substr (setq s (vla-get-textstring x))
                              1
                              (setq i (- (vl-string-search "." s) 2))
                      )
                      "-"
                      (substr s (1+ i))
              )
            )
          )
        )
      )
      (*error* nil)
    )
    Last edited by BlackBox; 2013-07-02 at 01:58 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Re: Modify Text

    Hi Blackbox,

    that returns "error too many arguments"

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify Text

    Quote Originally Posted by feargt View Post
    Hi Blackbox,

    that returns "error too many arguments"
    Oops! That's what I get for writing code within my post, rather than in VLIDE... Code corrected... Give it another try?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify Text

    I made one more minor edit to the selection set filter, to preclude the selection of text that already includes the hyphen ("*-##.*").
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    100 Club
    Join Date
    2015-09
    Posts
    154
    Login to Give a bone
    0

    Default Re: Modify Text

    Thanks, that has done the trick. And it is also allows me to create variations of the command too!

    Thanks

  9. #9
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Modify Text

    Quote Originally Posted by feargt View Post
    Thanks, that has done the trick. And it is also allows me to create variations of the command too!

    Thanks
    You're welcome; I'm happy to help.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. To modify leaders by where they attach to the text box
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2015-11-12, 07:00 PM
  2. cannot modify text box
    By mmiles in forum Design Review - General
    Replies: 1
    Last Post: 2011-11-14, 07:38 AM
  3. Modify text in multileader
    By bowtle in forum AutoLISP
    Replies: 9
    Last Post: 2010-04-20, 03:04 PM
  4. Stretch/modify model text
    By patricks in forum Revit Architecture - General
    Replies: 1
    Last Post: 2007-05-08, 04:21 PM
  5. modify existing text objects
    By ccowgill in forum AutoLISP
    Replies: 4
    Last Post: 2005-11-04, 02:35 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
  •