Jump to content

Erasing the text in the 2nd line of an Mtext


LearningLisP

Recommended Posts

Not necessary, in case DXF 1 started with either "\\P" or "\n" and the next line of text didn't start until somewhere within the DXF 3 block perhaps.

254+ characters later

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    11

  • Lee Mac

    6

  • LearningLisP

    5

  • Tharwat

    2

Top Posters In This Topic

Posted Images

*shrug* just throwing it out there :)

uglyToLookAt.gif

My point was that if we're using the filter within ssget (since it only searches the first matching pair), it's kind of pointless to step through the entire entity data dump when it's only concerning itself with the first.

 

Boy, you will argue with a post. LoL

Link to comment
Share on other sites

Just for grins and giggles (using my modded example):

 

(defun c:test (/ ss i e s)
 (vl-load-com)

 (if (setq ss (ssget "_:L" '((0 . "MTEXT"))))
   (repeat (setq i (sslength ss))
     (if (cond ((vl-string-search
                  "\\P"
                  (setq s (apply 'strcat
                                 (mapcar '(lambda (x)
                                            (if (vl-position (car x) '(1 3))
                                              (cdr x)
                                              ""
                                            )
                                          )
                                         (entget (setq e (ssname ss (setq i (1- i)))))
                                 )
                          )
                  )
                )
               )
               ((vl-string-search "\n" s))
         )
       (vla-put-Textstring
         (vlax-ename->vla-object e)
         (car
           (vl-remove
             ""
             (read
               (strcat "(\"" (LM:StringSubst "\" \"" "\\P" (LM:StringSubst "\" \"" "\n" s)) "\")")
             )
           )
         )
       )
     )
   )
 )
 (princ)
)
(defun LM:StringSubst (new old string / l i)
 (setq l (strlen new)
       i 0
 )
 (while (setq i (vl-string-search old string i))
   (setq string (vl-string-subst new old string i)
         i      (+ i l)
   )
 )
 string
)

Link to comment
Share on other sites

wow.. i thought this was solved.. :).. you guys are genius!! thanks!

 

@Thalwart

ah ok.. maybe it wont work in an older version. thanks!

Link to comment
Share on other sites

hey alan, tested your code and unfortunately, it did not work on me. i guess its my CAD version. thanks for updating it. :)

Link to comment
Share on other sites

  • 2 years later...
  • 5 years later...

IS THERE ANY CHOICE OPTION, any one can provide a lisp 

MAY BE IN SOME MTEXT I WANT REMOVE ABOVE 2 OR 3 LINE

MAY BE IN SOME MTEXT I WANT REMOVE BELOW ONE LINE (2 OR 3) .

 

*** MUST BE ASK CHOICE  (FROM ABOVE 1,2,3......OR FROM BELOW 1,2.3.....) LIKE THAT

 

THANKS 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...