- 积分
- 15637
- 明经币
- 个
- 注册时间
- 2012-8-20
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2020-5-7 14:10:27
|
显示全部楼层
- ;; Text1MtextJust.lsp [command name: T1MJ]
- ;http://cadtips.cadalyst.com/multiline-text/convert-text-mtext-without-changing-justification
- ;; TXT2MTXT command does not preserve all aspects of justification. For
- ;; one selected Text/Attribute-definition entity, retains horizontal component
- ;; [except Aligned/ Fit have Center imposed], but always imposes Top for
- ;; vertical component, regardless of Text entity's original justification.
- ;; T1MJ converts each selected Text or Attribute-Definition entity separately
- ;; to Mtext with same or equivalent justification as original Text, including
- ;; vertical component.
- ;; "Equivalent" for Text/Attribute justifications not used with Mtext:
- ;; Left/Center/Right become Bottom-Left/Bottom-Center/Bottom-Right;
- ;; Middle becomes Middle-Center;
- ;; Aligned/Fit become Bottom-Center with new insertion point half-way
- ;; between original Text entity's baseline alignment/fit points, so that
- ;; any positional change is minimized.
- ;; Will sometimes result in slight positional change, depending on specific
- ;; justification involved, text font, and/or whether text content includes
- ;; characters extending above or below height of capital letters [e.g. lower-
- ;; case letters with descenders, parentheses/brackets/braces, slashes, etc.].
- ;; Fit-justified object will retain original height, but lose width adjustment.
- ;; Kent Cooper, last edited 27 August 2014
- ;单行文本转多行文本,并且保留对齐方式
- (defun C:T1MJ ; = Text or Attribute Definition to 1-line Mtext, retaining Justification
- (/ *error* cmde doc tss inc tent tobj tins tjust)
- (defun *error* (errmsg)
- (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
- (princ (strcat "\nError: " errmsg))
- ); if
- (vla-endundomark doc)
- (setvar 'cmdecho cmde)
- (princ)
- ); defun - *error*
- (setq
- cmde (getvar 'cmdecho)
- doc (vla-get-activedocument (vlax-get-acad-object))
- ); setq
- (vla-startundomark doc)
- (setvar 'cmdecho 0)
- (prompt "\nTo change Text/Attribute to 1-line Mtext, preserving Justification,")
- (if (setq tss (ssget "_:L" '((0 . "TEXT"))))
- (repeat (setq inc (sslength tss))
- (setq
- tent (ssname tss (setq inc (1- inc)))
- tobj (vlax-ename->vla-object tent)
- tins (vlax-get tobj 'TextAlignmentPoint)
- tjust (vla-get-Alignment tobj)
- ); setq
- (cond
- ((= tjust 0) (setq tjust 7 tins (vlax-get tobj 'InsertionPoint))); Left
- ((< tjust 3) (setq tjust (+ tjust 7))); 1/2 [Center/Right] to 8/9
- ((= tjust 4) (setq tjust 5)); Middle to Middle-Center
- ((member tjust '(3 5)); Aligned/Fit
- (setq
- tjust 8 ; to Bottom-Center
- tins (mapcar '/ (mapcar '+ (vlax-get tobj 'InsertionPoint) tins) '(2 2 2))
- ; with new insertion point
- ); setq
- ); Aligned/Fit
- ((setq tjust (- tjust 5))); all vertical-horizontal pair justifications
- ); cond
- (if (= (vla-get-TextString tobj) "") (vla-put-TextString tobj (vla-get-TagString tobj)))
- ;; if no default content, disappears after TXT2MTXT: impose Tag value for it
- ;; [to use Prompt value instead, change end to (vla-get-PromptString tobj).]
- (command "_.txt2mtxt" tent ""); convert, then
- (setq tobj (vlax-ename->vla-object (entlast))); replace Text as object with new Mtext
- (vla-put-AttachmentPoint tobj tjust); original Text's justification [or equiv.]
- (vlax-put tobj 'InsertionPoint tins); original Text's insertion
- ); repeat
- ); if
- (setvar 'cmdecho cmde)
- (vla-endundomark doc)
- (princ)
- ); defun -- T1MJ
- (vl-load-com)
- (prompt "\nType T1MJ to change Text/Attribute-Definitions to 1-line Mtext, preserving Justification.")
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|