Jump to content

Block + Mtext---> convert to Block + attribute


bono05

Recommended Posts

Only if it's not to much work....

 

Possible to retain de position and rotation of mtext? Because after lisp i need to move one by one to a confortable position to read it.

Link to comment
Share on other sites

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • bono05

    12

  • Tharwat

    7

  • ttray33y

    5

  • AIberto

    2

Top Posters In This Topic

Posted Images

All right , this should do the trick in one shot :)

 

(defun c:Test (/ il ml s i sn en v d lst)
 ;;------------------------------------;;
 ;;	Tharwat 28.4.2015		;;
 ;;------------------------------------;;
 (princ "\nSelect Attributed Blocks with Mtexts:")
 (if (setq s (ssget "_:L"
                    '((-4 . "<OR")
                      (-4 . "<AND")
                      (0 . "INSERT")
                      (66 . 1)
                      (-4 . "AND>")
                      (0 . "MTEXT")
                      (-4 . "OR>")
                     )
             )
     )
   (progn
     (repeat (setq i (sslength s))
       (setq sn (ssname s (setq i (1- i)))
             en (entget sn)
       )
       (if (eq (cdr (assoc 0 en)) "INSERT")
         (setq il (cons (list (cdr (assoc 10 en)) sn) il))
         (setq ml (cons (list (cdr (assoc 10 en)) sn) ml))
       )
     )
     (mapcar
       '(lambda (u)
          (mapcar
            '(lambda (p)
               (setq
                 lst (cons (list (distance (car u) (car p)) (cadr p))
                           lst
                     )
               )
             )
            ml
          )
          (setq v (vl-sort lst '(lambda (j k) (< (car j) (car k)))))
          (mapcar '(lambda (o)
                     (if (eq (strcase (vla-get-tagstring o)) "COOR")
                       (progn
                         (vla-put-textstring
                           o
                           (vl-string-subst
                             ""
                             "\\P"
                             (cdr (assoc 1 (entget (cadar v))))
                           )
                         )
                         (setq d (cons (cadar v) d))
                       )
                     )
                   )
                  (vlax-invoke
                    (vlax-ename->vla-object (cadr u))
                    'getattributes
                  )
          )
          (setq v   nil
                lst nil
          )
        )
       il
     )
     (mapcar 'entdel d)
   )
 )
 (princ)
)(vl-load-com)

 

Nice . Dear Tharwat.

But maybe like this:

2015-04-28.png

Link to comment
Share on other sites

Only if it's not to much work....

 

Possible to retain de position and rotation of mtext? Because after lisp i need to move one by one to a confortable position to read it.

 

The Mtext string would take the place of the attribute that has the tag name COOR but we can change the rotation of the attribute inside the block according to the Mtext object's rotation angle .

 

But for the position of the attribute , I think it should be relocated manually .

 

NOTE: run the program on a few blocks and Mtext object because the closest Mtext string to the insertion point of the Attributed Block is the one that would be considered and it might duplicate the same text string into two blocks .

Link to comment
Share on other sites

Thank you Alberto :)

 

Where did you get that sim sun and hello text strings from ? :lol:

 

I enter a new strings , simsun is a font .:lol:

Link to comment
Share on other sites

  • 5 years later...

Is it possible to capture the text rotation value and have the new block match it?  I have no idea how to do this but it would prove VERY awesome if so.  Thanks guys!

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