See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: Move MText at a certain Z value LISP

  1. #1
    Member
    Join Date
    2013-11
    Posts
    3
    Login to Give a bone
    0

    Question Move MText at a certain Z value LISP

    Someone please help me with this issue:
    I would need a lisp routine to move the MText from Z value = 0 to the value written in the text. Example: If the MText says 20.435 I need that this text to be moved to Z value of 20.435.
    The thing is that I have 1000s of text on position Z=0 and I was asked to move all of it to the height that is written in it.
    I've checked on Google but couldn't find anything.
    To make it even more complicated, the MText doesn't have just the height written, but it's something like TOP= 20.435.
    I would be very grateful if any of you can create a Lisp routine to make my life easier.

    Cheers

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: Move MText at a certain Z value LISP

    Try this ...

    Code:
    (defun c:Test (/ s )
    ;; Tharwat 26.11.2013  ;;
      (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
        ((lambda (u / n p x e)
           (while (setq n (ssname s (setq u (1+ u))))
             (if (and (numberp (read (setq x (cdr (assoc 1 (setq e (entget n)))))))
                      (not (vl-string-search "\\P" x))
                      )
               (entmod (subst (cons 10 (list (car (setq p (cdr (assoc 10 e))))
                                             (cadr p)
                                             (atof x)
                                             ))
                              (assoc 10 e) e))
               )
             )
           ) -1)
        )
      (princ))

  3. #3
    Member
    Join Date
    2013-11
    Posts
    3
    Login to Give a bone
    0

    Default Re: Move MText at a certain Z value LISP

    Thank you very much! Very quick reply!
    Works perfect when you have just the digits in the text!
    I was wondering if you can make a change and add something so that will recognize the digits from a text as I've said in the previous message. All the text that I have is like this: TOP=20.630 ... and the code doesn't work in this case.
    Cheers.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Move MText at a certain Z value LISP

    Quote Originally Posted by djin_fre3449006 View Post
    Thank you very much! Very quick reply!
    Works perfect when you have just the digits in the text!
    I was wondering if you can make a change and add something so that will recognize the digits from a text as I've said in the previous message. All the text that I have is like this: TOP=20.630 ... and the code doesn't work in this case.
    Cheers.
    You're welcome .

    Try this modified one to meet your needs and let me know .

    Code:
    (defun c:Test (/ s)
      ;; Tharwat 26.11.2013  ;;
      (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
        ((lambda (u / n p x e z)
           (while (setq n (ssname s (setq u (1+ u))))
             (if (and (setq
                        z
                         (vl-list->string
                           (vl-remove-if-not
                             (function (lambda (i) (or (< 47 i 58) (eq 46 i))))
                             (vl-string->list
                               (setq x (cdr (assoc 1 (setq e (entget n)))))
                             )
                           )
                         )
                      )
                      (not (vl-string-search "\\P" x))
                 )
               (entmod (subst (cons 10
                                    (list (car (setq p (cdr (assoc 10 e))))
                                          (cadr p)
                                          (atof z)
                                    )
                              )
                              (assoc 10 e)
                              e
                       )
               )
             )
           )
         )
          -1
        )
      )
      (princ)
    )
    (vl-load-com)

  5. #5
    Member
    Join Date
    2013-11
    Posts
    3
    Login to Give a bone
    0

    Default Re: Move MText at a certain Z value LISP

    Thank you so much.. You made my day! Works perfect for what I need.

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Move MText at a certain Z value LISP

    Quote Originally Posted by djin_fre3449006 View Post
    Thank you so much.. You made my day! Works perfect for what I need.
    You're welcome anytime

Similar Threads

  1. LISP to move up or down
    By j.p.lackey678678 in forum AutoLISP
    Replies: 2
    Last Post: 2014-11-24, 07:25 PM
  2. Mtext in LISP
    By ticad02 in forum AutoLISP
    Replies: 4
    Last Post: 2009-04-21, 01:59 PM
  3. Move 3D LISP
    By tollyboy22 in forum AutoLISP
    Replies: 6
    Last Post: 2006-04-13, 05:59 PM
  4. Move Lisp
    By lmitsou in forum AutoLISP
    Replies: 2
    Last Post: 2006-02-24, 02:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •