masterfal 发表于 2022-7-5 18:10:54

文本对齐方式

大家好,
 
我想知道是否有人可以帮助编辑lee macs align text lisp,使文本对齐时不会改变文本在“y”方向的位置。当我运行这个程序时,它会将所有文本在x方向上移动以对齐,这很好,但它也会将文本在y方向上移动,因此它们的间距都是相等的。如果有人能让我知道如何防止文本向y方向移动,那太好了
 
希望它最终看起来像下面的最后一张图片,而不是第二张。我还附上了lisp文件的副本
 
(或者,如果有人能给我指出一个不同的lisp文件,可以实现我所描述的功能,那也太好了!)
 
编辑-忘了说谢谢李mac在第一时间创造了这个!李-麦克Lisp程序很厉害。干得好



对齐文本V1-3。lsp

iconeo 发表于 2022-7-5 18:18:30

为什么不直接使用JUSTIFYTEXT?

masterfal 发表于 2022-7-5 18:24:52

因为除非我遗漏了什么,否则这实际上不会对齐文本,是吗?

Lee Mac 发表于 2022-7-5 18:31:29

请尝试以下操作:
;;--------------------=={ Align Text }==----------------------;;
;;                                                            ;;
;;This program enables the user to reposition a selection   ;;
;;of text objects equispaced by a factor of the text height ;;
;;and aligned in a direction perpendicular to the rotation;;
;;angle of the text.                                        ;;
;;                                                            ;;
;;The program assumes all text objects in the selection   ;;
;;have the same rotation and will align each text object    ;;
;;using its Text Alignment Point.                           ;;
;;                                                            ;;
;;The program will perform successfully with text         ;;
;;constructed in any UCS plane.                           ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;Version 1.3    -    23-04-2013                            ;;
;;------------------------------------------------------------;;
;;Modified to retain vertical spacing - LM 2016-01-15       ;;
;;------------------------------------------------------------;;

(defun c:at ( / *error* ang bpt enx inc ins lst ocs sel vc1 vc2 )

   (defun *error* ( msg )
       (LM:endundo (LM:acdoc))
       (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
         (princ (strcat "\nError: " msg))
       )
       (princ)
   )

   (if (setq sel (ssget "_:L" '((0 . "TEXT"))))
       (progn
         (setq inc (sslength sel)
               enx (entget (ssname sel (1- inc)))
               ang (cdr (assoc 50 enx))
               ocs (trans '(0.0 0.0 1.0) 1 0 t)
               vc1 (trans (list    (cos ang)(sin ang)) ocs 0)
               vc2 (trans (list (- (sin ang)) (cos ang)) ocs 0)
         )
         (repeat inc
               (setq enx (entget (ssname sel (setq inc (1- inc))))
                     lst (cons (list(trans (aligntext:gettextinsertion enx) (cdr (assoc -1 enx)) 0) enx) lst)
                     ins (cons (caddr (trans (caar lst) 0 vc2)) ins)
               )
         )
         (setq lst (mapcar '(lambda ( n ) (nth n lst)) (vl-sort-i ins '>))
               bpt (caddr (trans (caar lst) 0 vc1))
         )
         (LM:startundo (LM:acdoc))
         (foreachitm (cdr lst)
               (setq ins (trans (car itm) 0 vc1))
               (aligntext:puttextinsertion
                   (trans (list (car ins) (cadr ins) bpt) vc1 (cdr (assoc -1 (cadr itm))))
                   (cadr itm)
               )
         )
         (LM:endundo (LM:acdoc))
       )
   )
   (princ)
)

(defun aligntext:getdxfkey ( enx )
   (if
       (and
         (zerop (cdr (assoc 72 enx)))
         (zerop (cdr (assoc 73 enx)))
       )
       10 11
   )
)

(defun aligntext:gettextinsertion ( enx )
   (cdr (assoc (aligntext:getdxfkey enx) enx))
)

(defun aligntext:puttextinsertion ( ins enx )
   (   (lambda ( key )
         (if (entmod (subst (cons key ins) (assoc key enx) enx))
               (entupd (cdr (assoc -1 enx)))
         )
       )
       (aligntext:getdxfkey enx)
   )
)

;; Start Undo-Lee Mac
;; Opens an Undo Group.

(defun LM:startundo ( doc )
   (LM:endundo doc)
   (vla-startundomark doc)
)

;; End Undo-Lee Mac
;; Closes an Undo Group.

(defun LM:endundo ( doc )
   (while (= 8 (logand 8 (getvar 'undoctl)))
       (vla-endundomark doc)
   )
)

;; Active Document-Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc nil
   (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
   (LM:acdoc)
)

(vl-load-com) (princ)

;;------------------------------------------------------------;;
;;                         End of File                        ;;
;;------------------------------------------------------------;;
 
我很高兴你发现这个程序很有用!

masterfal 发表于 2022-7-5 18:37:58

哦,哇。太棒了
星期一我第一件事就回来工作时,我会检查一下,然后告诉你进展如何。
非常感谢您的调查

Lee Mac 发表于 2022-7-5 18:41:21

不客气-我也会在我的网站上更新程序,将其作为一个选项。
 
您(和其他人)是否认为应该提示用户输入行距系数,并选择保留现有间距作为默认值?例如。:
Specify line spacing factor <use existing spacing>:
或者这应该由硬编码到程序中的参数控制,用户可以将该参数设置为零以保留现有间距?

halam 发表于 2022-7-5 18:47:49

认为让用户决定的功能将在以后保存您的请求。我更喜欢那样。

masterfal 发表于 2022-7-5 18:54:14

就我个人而言,我不认为我真的需要使用垂直间距。我主要是在追求它,所以我可以使绘图更整洁,不需要花太多时间。如果改变垂直间距,那么我认为需要长时间调整所有引线。如果领导者只需要水平拉伸,那么只需几秒钟即可完成。一旦音符垂直移动,那么显然,引线端需要垂直和水平移动
 
如果你看这些图像,你可以想象如果这些音符也垂直移动,那么需要更多的时间/精力来修复所有的引线,使它们再次与音符相遇。
 
另外,我认为我的文字的垂直位置通常是正确的。我不想让一张纸条把reo的名字写在计划的底部,结果却被直接移到了顶部。这真的没有道理。。在相同的垂直间距下,音符似乎可以混合成一个巨大的音符,所以不同的间距使它更容易阅读
 
我也很高兴把它作为一种选择。我只是想解释一下如何使用它

Lee Mac 发表于 2022-7-5 18:56:37

谢谢你们的反馈,非常感谢。
 
@masterfal,如果要在图形中使用多重引线,则可以使用标准的多重引线对齐命令对齐这些引线。尽管如此,我很高兴听到您发现我的对齐文本程序很有用,并且修改后的程序在您的图形中运行良好。

Lee Mac 发表于 2022-7-5 19:03:02

我现在已经根据这个帖子的反馈和建议更新了我的对齐文本程序。
 
页: [1] 2
查看完整版本: 文本对齐方式