(defun C:MT2T
(/ ss ent cnt obj ss2 ent2 cnt2 obj2 mtap just le oldip
oldap newip di ag newap _GetTextAlignment _MarkLastEnt
_Buildss _error)
; Error Handler sub-function
(princ "\nProgram Aborted.\n") )
(and err
-bak
(setq *error* err
-bak
)) (*error* msg)
)
); end sub-function
; sub-function "_MarkLastEnt"
; Marks the last entity in the drawing. Makes sure sub-entities are cycled and
; prevents error in blank drawing by making a marker entity.
(defun _MarkLastEnt
(/ e en
) )
)
)
en
) ; End sub-function
; Sub-Function "_Buildss"
; Builds a selection set from any entities added in a drawing
; from a marked entity.
(defun _Buildss
(en
/ ss
) )
)
ss
) ; End sub-function
; sub-function "_GetTextAlignment"
; Converts MTEXT attachment point enum to closest TEXT alignment enum
(defun _GetTextAlignment
(just
/ prop
) ((= just
acAttachmentPointBottomLeft)(setq prop
acAlignmentLeft)) ((= just
acAttachmentPointBottomRight)(setq prop acAlignmentRight
)) ((= just
acAttachmentPointBottomCenter)(setq prop acAlignmentCenter
)) ((= just
acAttachmentPointMiddleLeft)(setq prop acAlignmentMiddleLeft
)) ((= just
acAttachmentPointMiddleRight)(setq prop acAlignmentMiddleRight
)) ((= just
acAttachmentPointMiddleCenter)(setq prop
acAlignmentMiddle)) ((= just
acAttachmentPointTopLeft)(setq prop acAlignmentTopLeft
)) ((= just
acAttachmentPointTopCenter)(setq prop acAlignmentTopCenter
)) ((= just
acAttachmentPointTopRight)(setq prop acAlignmentTopRight
)) )
prop
) ; End sub-function
; Set error handler
(setq err
-bak
*error* *error* _error
) ; Set UNDO mark.
; Disable command line echo
(prompt "\nSelect MTEXT Object(s) to Explode: ") ; Test to see if there are MTEXT entities selected.
; If so, Start a loop reading each entity in the selection set of MTEXT objects.
; Get the attachment point of the MTEXT object
; Convert to a TEXT alignment point.
just (_GetTextAlignment mtap)
; Mark the last object in the drawing.
le (_MarkLastEnt)
)
; EXPLODE the MTEXT object.
; Build a new selection set of the resulting TEXT entities and reset the 2nd loop counter.
(setq ss2
(_Buildss le
) cnt2
nil) ; start 2nd loop to iterate through the TEXT entities.
; Get the TEXT ActiveX Object
; Get the Insertion Point of the TEXT
; Get the Alignment point of the TEXT
)
; Change the Alignment point to the converted MTEXT value
; Get the new insertion point after the TEXT alignment has changed.
; Get the distance and angle from the new insertion point to the old one.
; Map the new alignment point location.
)
; Change the TEXT alignment point.
); End loop
); End Loop
); End If
; Restore the default error handler
(if err
-bak
(setq *error* err
-bak err
-bak
nil)) ; End UNDO Mark.
; Exit quietly
); End Command