Jump to content

Lisp for remove one line from mtext


gmmdinesh

Recommended Posts

Why doesn't it work properly on my file?

 

(defun C:mtfr2 (/ ent strent ans newline x k ssmtxt removetxt)
  (setq ssmtxt (ssget '((0 . "Mtext"))))
  (setq x (getint "\nLine To Remove: "))
  (repeat (setq k (sslength ssmtxt))
    (setq strent (vlax-ename->vla-object (ssname ssmtxt (setq k (- k 1)))))
    (setq str (vla-get-textstring strent))
    (setq ans (LM:csv->lst str "\\" 0))
    (setq removetxt (nth (- x 1) ans))
    (setq newline "")
    (setq x 0)
    (repeat (length ans)
      (if (= (wcmatch (strcase (nth x ans)) (strcase removetxt)) T) ;doesn't need a wild card.
        (princ)
        (setq newline (strcat newline "\\" (nth x ans)))
      )
      (setq x (+ x 1))
    )
    (if (eq (vl-string-search "\\P" newline) 0) 
      (setq newline (substr newline 3))
      (setq newline (substr newline 2))
    )
    (vla-put-textstring strent newline)
  )  ; repeat
  (princ)
)

Test.dwg

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...