Lisp for transforming several texts into the same several different mtext

Lisp for transforming several texts into the same several different mtext

virgilius99
Contributor Contributor
2,697 Views
11 Replies
Message 1 of 12

Lisp for transforming several texts into the same several different mtext

virgilius99
Contributor
Contributor

Hi, I need a lisp for transforming several texts into the same several different mtext, thx!

0 Likes
Accepted solutions (1)
2,698 Views
11 Replies
Replies (11)
Message 2 of 12

CodeDing
Advisor
Advisor

@virgilius99 ,

 

Do you have Express Tools loaded? If so, have you tried the TXT2MTXT command?

 

Best,

~DD

0 Likes
Message 3 of 12

virgilius99
Contributor
Contributor

yes, take a look at drawing in att, thx

0 Likes
Message 4 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

Try Text1MtextJust.lsp with its T1MJ command, available >here<.  Not only does it convert individual Text objects into individual separate Mtext objects, but it also does it to Attribute definitions, and it preserves all aspects of justification, which TXT2MTXT does not always do.

Kent Cooper, AIA
Message 5 of 12

dlanorh
Advisor
Advisor

At its most basic

 

 

(defun c:T2MT (/ c_doc sv_lst sv_vals ss cnt)

  (vl-load-com)

  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        sv_lst (list 'cmdecho 'osmode)
        sv_vals (mapcar 'getvar sv_lst)
  );_end_setq

  (mapcar 'setvar sv_lst '(0 0))

  (setq ss (ssget '((0 . "TEXT"))))
  
  (cond (ss
          (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark c_doc))
          (vla-startundomark c_doc)

          (repeat (setq cnt (sslength ss))
            (vl-cmdf "txt2mtxt" (ssname ss (setq cnt (1- cnt))) "")
          )

          (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
        )
  )
  
  (mapcar 'setvar sv_lst sv_vals)
  (princ)
)

 

 

I am not one of the robots you're looking for

Message 6 of 12

virgilius99
Contributor
Contributor

this is it! thx you!

0 Likes
Message 7 of 12

krazeymike
Enthusiast
Enthusiast

Is it easy to add a Bottom Centre justification to the created MText?

0 Likes
Message 8 of 12

Kent1Cooper
Consultant
Consultant

@krazeymike wrote:

Is it easy to add a Bottom Centre justification to the created MText?


If the source Text object is justified that way, T1MJ will make the Mtext conversion likewise.  If not, this will give the VLA object version [the obj variable here] of an Mtext object that justification:

(vla-put-AttachmentPoint obj 8)

Kent Cooper, AIA
0 Likes
Message 9 of 12

krazeymike
Enthusiast
Enthusiast

Thankyou Kent, I'm just not sure how to add (vla-put-AttachmentPoint obj 8) into the M2MT Lisp above

0 Likes
Message 10 of 12

Kent1Cooper
Consultant
Consultant

@krazeymike wrote:

Thankyou Kent, I'm just not sure how to add (vla-put-AttachmentPoint obj 8) into the M2MT Lisp above


Do you mean T2MT in Message 5?  If so, I hope just adding a line [here, line 3] would do it [untested]:

          (repeat (setq cnt (sslength ss))
            (vl-cmdf "txt2mtxt" (ssname ss (setq cnt (1- cnt))) "")
            (vla-put-AttachmentPoint (vlax-ename->vla-object (entlast)) 8)
          )

[That assumes that the TXT2MTXT conversion inside there results in a new entity name, as it does manually.]

Kent Cooper, AIA
0 Likes
Message 11 of 12

krazeymike
Enthusiast
Enthusiast

Yes I did mean T2MT on in message 5.
Pasting it into Line 3 wouldn't run but placing it before the (princ) on line 27 worked like a charm.
Thankyou

0 Likes
Message 12 of 12

krazeymike
Enthusiast
Enthusiast

(Original Edited)
I went a bit off topic here, can't delete so I have edited instead. Thanks for the help Kent 

 

I have a Lisp routine that converts mText or Text to blocks about the insertion point. The only problem is that no matter the justification standard text is always inserted to the left node rather than the centre.
I'm not sure what causes standard text insertion to default to the left node and so am not sure where to look to correct this. 

0 Likes