乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 90|回复: 11

[编程交流] 偏移多个文本

[复制链接]

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 19:58:50 | 显示全部楼层 |阅读模式
你好:
 
是否有可以将多个文本偏移指定距离的命令?
 
或者一些lsp例程可以完成这项工作?即使是一个可以将单个文本向任意一侧偏移指定距离的例程也会很有帮助。我对lsp程序比较陌生。我们将非常感谢您的帮助。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:08:47 | 显示全部楼层
欢迎来到论坛
 
您是否在系统变量(mirrtext)设置为0的情况下尝试了命令:mirror?
回复

使用道具 举报

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 20:12:58 | 显示全部楼层
 
 
谢谢你的回复。
不幸的是,对于我需要完成的任务,mirror命令没有多大帮助。因为需要移动的文本太多,但并非所有文本都需要移动一定距离。有些文本需要移动到现有文本的一侧一定距离,有些文本需要移动到现有文本的另一侧。
我确实在2000年找到了蒂姆·B·韦伯的lsp。lsp代码可以偏移文本。该规范的局限性如下:
·它只能将文本偏移代码中预先指定的距离意味着您不能指定偏移距离
·一次只能偏移一个文本。
·它只能将文本偏移到现有文本的左侧–意味着您不能将文本偏移到另一侧。
这种lsp的优点是它可以偏移文本,因此图层和颜色保持不变。这要归功于lsp的创始人。
我试图修改lsp以克服局限性,但收效甚微。有人能帮忙吗?
请参阅下面的原始lsp。
 
  1. ;Tip1634:   OFFTX.LSP     Offset Text            (c)2000, Tim B. Webb[/font][/size]
  2. [font=Calibri][size=3] [/size][/font]
  3. [size=3][font=Calibri] (defun C:OFFTX (/ FTR HT STYL IF72 IF73 COLOR QUACKAS8 AS62CLY CLRS TIMS OLDERR RT ANG ANG1[/font][/size]
  4. [size=3][font=Calibri]                TXVAL ASS10 ASS11 NXT PRMPT CURTX)[/font][/size]
  5. [size=3][font=Calibri]   (setvar "cmdecho" 0)[/font][/size]
  6. [size=3][font=Calibri]   (setq OLDERR *ERROR*)[/font][/size]
  7. [size=3][font=Calibri]   (setq *ERROR* TRAPERR)[/font][/size]
  8. [size=3][font=Calibri]   (setq TIMS t)[/font][/size]
  9. [size=3][font=Calibri]   (setq CLRS (getvar "cecolor"))[/font][/size]
  10. [size=3][font=Calibri]   (setq CLY (getvar "clayer"))[/font][/size]
  11. [size=3][font=Calibri]   (initget "O o N n")[/font][/size]
  12. [size=3][font=Calibri]   (setq PRMPT (getkword "\n<Offset>/New text: "))[/font][/size]
  13. [size=3][font=Calibri]   (if (or (= PRMPT "N") (= PRMPT "n"))[/font][/size]
  14. [size=3][font=Calibri]      (progn (while (= CURTX NIL) (setq CURTX (car (entsel "\nText to offset: "))))[/font][/size]
  15. [size=3][font=Calibri]             (setq TXSTR (prompt "\nText: "))[/font][/size]
  16. [size=3][font=Calibri]             (setq QUACK (entget CURTX))[/font][/size]
  17. [size=3][font=Calibri]             (setq AS8 (cdr (assoc 8 QUACK)))[/font][/size]
  18. [size=3][font=Calibri]             (setvar "clayer" AS8)[/font][/size]
  19. [size=3][font=Calibri]             (if (= (setq AS62 (cdr (assoc 62 QUACK))) NIL)[/font][/size]
  20. [size=3][font=Calibri]                (setq COLOR "bylayer")[/font][/size]
  21. [size=3][font=Calibri]                (setq COLOR AS62)[/font][/size]
  22. [size=3][font=Calibri]             ) ;_ end of if[/font][/size]
  23. [size=3][font=Calibri]             (setq IF72 (cdr (assoc 72 QUACK)))[/font][/size]
  24. [size=3][font=Calibri]             (setq IF73 (cdr (assoc 73 QUACK)))[/font][/size]
  25. [size=3][font=Calibri]             (cond ((and (= IF72 0) (= IF73 0)) (setq TYPEX "L"))[/font][/size]
  26. [size=3][font=Calibri]                   ((and (= IF72 1) (= IF73 0)) (setq TYPEX "C"))[/font][/size]
  27. [size=3][font=Calibri]                   ((and (= IF72 4) (= IF73 2)) (setq TYPEX "M"))[/font][/size]
  28. [size=3][font=Calibri]                   ((and (= IF72 4) (= IF73 0)) (setq TYPEX "M"))[/font][/size]
  29. [size=3][font=Calibri]                   ((and (= IF72 2) (= IF73 0)) (setq TYPEX "R"))[/font][/size]
  30. [size=3][font=Calibri]                   ((and (= IF72 0) (= IF73 3)) (setq TYPEX "TL"))[/font][/size]
  31. [size=3][font=Calibri]                   ((and (= IF72 1) (= IF73 3)) (setq TYPEX "TC"))[/font][/size]
  32. [size=3][font=Calibri]                   ((and (= IF72 2) (= IF73 3)) (setq TYPEX "TR"))[/font][/size]
  33. [size=3][font=Calibri]                   ((and (= IF72 0) (= IF73 2)) (setq TYPEX "ML"))[/font][/size]
  34. [size=3][font=Calibri]                   ((and (= IF72 1) (= IF73 2)) (setq TYPEX "MC"))[/font][/size]
  35. [size=3][font=Calibri]                   ((and (= IF72 2) (= IF73 2)) (setq TYPEX "MR"))[/font][/size]
  36. [size=3][font=Calibri]                   ((and (= IF72 0) (= IF73 1)) (setq TYPEX "BL"))[/font][/size]
  37. [size=3][font=Calibri]                   ((and (= IF72 1) (= IF73 1)) (setq TYPEX "BC"))[/font][/size]
  38. [size=3][font=Calibri]                   ((and (= IF72 2) (= IF73 1)) (setq TYPEX "BR"))[/font][/size]
  39. [size=3][font=Calibri]             ) ;_ end of cond[/font][/size]
  40. [size=3][font=Calibri]             (setq HT (cdr (assoc 40 QUACK)))[/font][/size]
  41. [size=3][font=Calibri]             (setq STYL (cdr (assoc 7 QUACK)))[/font][/size]
  42. [size=3][font=Calibri]             (setvar "textstyle" STYL)[/font][/size]
  43. [size=3][font=Calibri]             (setq FTR (* HT 1.6667))[/font][/size]
  44. [size=3][font=Calibri]             (setq RT (cdr (assoc 50 QUACK)))[/font][/size]
  45. [size=3][font=Calibri]             (setq ANG (- RT (/ pi 2)))[/font][/size]
  46. [size=3][font=Calibri]             (setq ANG1 (/ (* RT 180) pi))[/font][/size]
  47. [size=3][font=Calibri]             (setq TXVAL (cdr (assoc 1 QUACK)))[/font][/size]
  48. [size=3][font=Calibri]             (if (= TYPEX "L")[/font][/size]
  49. [size=3][font=Calibri]                (progn (setq ASS10 (cdr (assoc 10 QUACK)))[/font][/size]
  50. [size=3][font=Calibri]                       (setq NXT (polar ASS10 ANG FTR))[/font][/size]
  51. [size=3][font=Calibri]                       (command "cecolor" COLOR)[/font][/size]
  52. [size=3][font=Calibri]                       (command "Dtext" NXT HT ANG1)[/font][/size]
  53. [size=3][font=Calibri]                ) ;_ end of progn[/font][/size]
  54. [size=3][font=Calibri]                (progn (setq ASS11 (cdr (assoc 11 QUACK)))[/font][/size]
  55. [size=3][font=Calibri]                       (setq NXT (polar ASS11 ANG FTR))[/font][/size]
  56. [size=3][font=Calibri]                       (command "cecolor" COLOR)[/font][/size]
  57. [size=3][font=Calibri]                       (command "Dtext" "j" TYPEX NXT HT ANG1)[/font][/size]
  58. [size=3][font=Calibri]                ) ;_ end of progn[/font][/size]
  59. [size=3][font=Calibri]             ) ;_ end of if[/font][/size]
  60. [size=3][font=Calibri]      ) ;_ end of progn[/font][/size]
  61. [size=3][font=Calibri]   ) ;_ end of if[/font][/size]
  62. [size=3][font=Calibri]   (if (or (= PRMPT "O") (= PRMPT "o") (= PRMPT NIL))[/font][/size]
  63. [size=3][font=Calibri]      (progn[/font][/size]
  64. [size=3][font=Calibri]         (while TIMS[/font][/size]
  65. [size=3][font=Calibri]            (setq TIMS (grread t 2 1))[/font][/size]
  66. [size=3][font=Calibri]            (if (= (cadr TIMS) 13)[/font][/size]
  67. [size=3][font=Calibri]               (setq TIMS NIL)[/font][/size]
  68. [size=3][font=Calibri]            ) ;_ end of if[/font][/size]
  69. [size=3][font=Calibri]            (if (= CURTX NIL)[/font][/size]
  70. [size=3][font=Calibri]               (progn (while (= CURTX NIL) (setq CURTX (car (entsel "\nText to offset: "))))[/font][/size]
  71. [size=3][font=Calibri]               ) ;_ end of progn[/font][/size]
  72. [size=3][font=Calibri]               (setq CURTX (car (entsel "\nText to offset: ")))[/font][/size]
  73. [size=3][font=Calibri]            ) ;_ end of if[/font][/size]
  74. [size=3][font=Calibri]            (if (= CURTX NIL)[/font][/size]
  75. [size=3][font=Calibri]               (setq TIMS NIL)[/font][/size]
  76. [size=3][font=Calibri]               (progn (setq QUACK (entget CURTX))[/font][/size]
  77. [size=3][font=Calibri]                      (setq AS8 (cdr (assoc 8 QUACK)))[/font][/size]
  78. [size=3][font=Calibri]                      (setvar "clayer" AS8)[/font][/size]
  79. [size=3][font=Calibri]                      (if (= (setq AS62 (cdr (assoc 62 QUACK))) NIL)[/font][/size]
  80. [size=3][font=Calibri]                         (setq COLOR "bylayer")[/font][/size]
  81. [size=3][font=Calibri]                         (setq COLOR AS62)[/font][/size]
  82. [size=3][font=Calibri]                      ) ;_ end of if[/font][/size]
  83. [size=3][font=Calibri]                      (setq IF72 (cdr (assoc 72 QUACK)))[/font][/size]
  84. [size=3][font=Calibri]                      (setq IF73 (cdr (assoc 73 QUACK)))[/font][/size]
  85. [size=3][font=Calibri]                      (cond ((and (= IF72 0) (= IF73 0)) (setq TYPEX "L"))[/font][/size]
  86. [size=3][font=Calibri]                            ((and (= IF72 1) (= IF73 0)) (setq TYPEX "C"))[/font][/size]
  87. [size=3][font=Calibri]                            ((and (= IF72 4) (= IF73 2)) (setq TYPEX "M"))[/font][/size]
  88. [size=3][font=Calibri]                            ((and (= IF72 4) (= IF73 0)) (setq TYPEX "M"))[/font][/size]
  89. [size=3][font=Calibri]                            ((and (= IF72 2) (= IF73 0)) (setq TYPEX "R"))[/font][/size]
  90. [size=3][font=Calibri]                            ((and (= IF72 0) (= IF73 3)) (setq TYPEX "TL"))[/font][/size]
  91. [size=3][font=Calibri]                            ((and (= IF72 1) (= IF73 3)) (setq TYPEX "TC"))[/font][/size]
  92. [size=3][font=Calibri]                            ((and (= IF72 2) (= IF73 3)) (setq TYPEX "TR"))[/font][/size]
  93. [size=3][font=Calibri]                            ((and (= IF72 0) (= IF73 2)) (setq TYPEX "ML"))[/font][/size]
  94. [size=3][font=Calibri]                            ((and (= IF72 1) (= IF73 2)) (setq TYPEX "MC"))[/font][/size]
  95. [size=3][font=Calibri]                            ((and (= IF72 2) (= IF73 2)) (setq TYPEX "MR"))[/font][/size]
  96. [size=3][font=Calibri]                            ((and (= IF72 0) (= IF73 1)) (setq TYPEX "BL"))[/font][/size]
  97. [size=3][font=Calibri]                            ((and (= IF72 1) (= IF73 1)) (setq TYPEX "BC"))[/font][/size]
  98. [size=3][font=Calibri]                            ((and (= IF72 2) (= IF73 1)) (setq TYPEX "BR"))[/font][/size]
  99. [size=3][font=Calibri]                      ) ;_ end of cond[/font][/size]
  100. [size=3][font=Calibri]                      (setq HT (cdr (assoc 40 QUACK)))[/font][/size]
  101. [size=3][font=Calibri]                      (setq STYL (cdr (assoc 7 QUACK)))[/font][/size]
  102. [size=3][font=Calibri]                      (setvar "textstyle" STYL)[/font][/size]
  103. [size=3][font=Calibri]                      (setq FTR (* HT 1.6667))[/font][/size]
  104. [size=3][font=Calibri]                      (setq RT (cdr (assoc 50 QUACK)))[/font][/size]
  105. [size=3][font=Calibri]                      (setq ANG (- RT (/ pi 2)))[/font][/size]
  106. [size=3][font=Calibri]                      (setq ANG1 (/ (* RT 180) pi))[/font][/size]
  107. [size=3][font=Calibri]                      (setq TXVAL (cdr (assoc 1 QUACK)))[/font][/size]
  108. [size=3][font=Calibri]                      (if (= TYPEX "L")[/font][/size]
  109. [size=3][font=Calibri]                         (progn (setq ASS10 (cdr (assoc 10 QUACK)))[/font][/size]
  110. [size=3][font=Calibri]                                (setq NXT (polar ASS10 ANG FTR))[/font][/size]
  111. [size=3][font=Calibri]                                (command "cecolor" COLOR)[/font][/size]
  112. [size=3][font=Calibri]                                (command "text" NXT HT ANG1 TXVAL)[/font][/size]
  113. [size=3][font=Calibri]                         ) ;_ end of progn[/font][/size]
  114. [size=3][font=Calibri]                         (progn (setq ASS11 (cdr (assoc 11 QUACK)))[/font][/size]
  115. [size=3][font=Calibri]                                (setq NXT (polar ASS11 ANG FTR))[/font][/size]
  116. [size=3][font=Calibri]                                (command "cecolor" COLOR)[/font][/size]
  117. [size=3][font=Calibri]                                (command "text" "j" TYPEX NXT HT ANG1 TXVAL)[/font][/size]
  118. [size=3][font=Calibri]                         ) ;_ end of progn[/font][/size]
  119. [size=3][font=Calibri]                      ) ;_ end of if[/font][/size]
  120. [size=3][font=Calibri]               ) ;_ end of progn[/font][/size]
  121. [size=3][font=Calibri]            ) ;_ end of if[/font][/size]
  122. [size=3][font=Calibri]         ) ;_ end of while[/font][/size]
  123. [size=3][font=Calibri]      ) ;_ end of progn[/font][/size]
  124. [size=3][font=Calibri]   ) ;_ end of if[/font][/size]
  125. [size=3][font=Calibri]   (setvar "clayer" CLY)[/font][/size]
  126. [size=3][font=Calibri]   (setvar "cecolor" CLRS)[/font][/size]
  127. [size=3][font=Calibri]   (princ "\nDone.")[/font][/size]
  128. [size=3][font=Calibri]   (setq *ERROR* OLDERR)[/font][/size]
  129. [size=3][font=Calibri]   (princ)[/font][/size]
  130. [size=3][font=Calibri]) ;_ end of defun[/font][/size]
  131. [font=Calibri][size=3] [/size][/font]
  132. [size=3][font=Calibri](defun TRAPERR (MSG)[/font][/size]
  133. [size=3][font=Calibri]   (if *ERROR*[/font][/size]
  134. [size=3][font=Calibri]      (princ (strcat "\nTrapped Error : " MSG))[/font][/size]
  135. [size=3][font=Calibri]   ) ;_ end of if[/font][/size]
  136. [size=3][font=Calibri]   (setq *ERROR* OLDERR)[/font][/size]
  137. [size=3][font=Calibri]   (princ)[/font][/size]
  138. [size=3][font=Calibri]) ;_ end of defun[/font][/size]
  139. [font=Calibri][size=3] [/size][/font]
  140. [font=Calibri][size=3] [/size][/font]
  141. [font=Calibri][size=3] [/size][/font]
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:17:47 | 显示全部楼层
请阅读此代码发布。
 
你想把一些文字移动到特定的距离吗?和其他人到另一个特定的距离?
 
如果是,请提及这两个距离,以便我将这些距离包括在例程中。
 
谢谢
回复

使用道具 举报

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 20:20:35 | 显示全部楼层
 
 
大多数时候,我需要偏移文本的距离是不同的。
是否可以编写例程,以便用户可以选择输入偏移距离?
我试图修改上面的代码来做到这一点,但这不是一件容易的事。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:26:21 | 显示全部楼层
希望这就是你的意思。
 
  1. (defun c:Test (/ ss rep dis i ssNme p)
  2. (vl-load-com)
  3. ; Tharwat 17. 06. 2011
  4. (if
  5.    (and (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT"))))
  6.         (progn (initget "Left Right")
  7.                (setq rep (getkword "\n Specify the Direction [left/Right]:"))
  8.         )
  9.         (setq dis (getdist "\n Specify the Distance :"))
  10.    )
  11.     (if (eq rep "Left")
  12.       (repeat
  13.         (setq i (sslength ss))
  14.          (setq ssNme (ssname ss (setq i (1- i))))
  15.          (vla-move
  16.            (vlax-ename->vla-object ssNme)
  17.            (vlax-3d-point (setq p (cdr (assoc 10 (entget ssNme)))))
  18.            (vlax-3d-point (list (- (car p) dis) (cadr p)))
  19.          )
  20.       )
  21.       (repeat
  22.         (setq i (sslength ss))
  23.          (setq ssNme (ssname ss (setq i (1- i))))
  24.          (vla-move
  25.            (vlax-ename->vla-object ssNme)
  26.            (vlax-3d-point (setq p (cdr (assoc 10 (entget ssNme)))))
  27.            (vlax-3d-point (list (+ (car p) dis) (cadr p)))
  28.          )
  29.       )
  30.     )
  31.     (princ)
  32. )
  33. (princ)
  34. )

 
塔瓦特
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:37:20 | 显示全部楼层
在这里,它适用于所有方向。
 
  1. (defun c:Test (/ ss rep dis i ssNme p)
  2. (vl-load-com)
  3. ; Tharwat 17. 06. 2011
  4. (if
  5.    (and (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT"))))
  6.         (progn (initget "Left Right Up Down")
  7.                (setq rep
  8.                       (getkword "\n Specify the Direction [left/Right/Up/Down]:"
  9.                       )
  10.                )
  11.         )
  12.         (setq dis (getdist "\n Specify the Distance :"))
  13.    )
  14.     (cond ((eq rep "Left")
  15.            (repeat
  16.              (setq i (sslength ss))
  17.               (setq ssNme (ssname ss (setq i (1- i))))
  18.               (vla-move
  19.                 (vlax-ename->vla-object ssNme)
  20.                 (vlax-3d-point (setq p (cdr (assoc 10 (entget ssNme)))))
  21.                 (vlax-3d-point (list (- (car p) dis) (cadr p)))
  22.               )
  23.            )
  24.           )
  25.           ((eq rep "Right")
  26.            (repeat
  27.              (setq i (sslength ss))
  28.               (setq ssNme (ssname ss (setq i (1- i))))
  29.               (vla-move
  30.                 (vlax-ename->vla-object ssNme)
  31.                 (vlax-3d-point (setq p (cdr (assoc 10 (entget ssNme)))))
  32.                 (vlax-3d-point (list (+ (car p) dis) (cadr p)))
  33.               )
  34.            )
  35.           )
  36.           ((eq rep "Up")
  37.            (repeat
  38.              (setq i (sslength ss))
  39.               (setq ssNme (ssname ss (setq i (1- i))))
  40.               (vla-move
  41.                 (vlax-ename->vla-object ssNme)
  42.                 (vlax-3d-point (setq p (cdr (assoc 10 (entget ssNme)))))
  43.                 (vlax-3d-point
  44.                   (list (car p) (+ (cadr p) dis))
  45.                 )
  46.               )
  47.            )
  48.           )
  49.           ((eq rep "Down")
  50.            (repeat
  51.              (setq i (sslength ss))
  52.               (setq ssNme (ssname ss (setq i (1- i))))
  53.               (vla-move
  54.                 (vlax-ename->vla-object ssNme)
  55.                 (vlax-3d-point (setq p (cdr (assoc 10 (entget ssNme)))))
  56.                 (vlax-3d-point
  57.                   (list (car p) (- (cadr p) dis))
  58.                 )
  59.               )
  60.            )
  61.           )
  62.     )
  63.     (princ)
  64. )
  65. (princ)
  66. )
Tharwat
回复

使用道具 举报

1

主题

4

帖子

3

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 20:41:58 | 显示全部楼层
多谢塔瓦!!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:47:36 | 显示全部楼层
 
不客气
回复

使用道具 举报

4

主题

57

帖子

53

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 20:51:08 | 显示全部楼层
干得好,塔尔瓦特。
 
自从你第一次帮助我以来,你的代码已经增强了。谢谢你,当时和现在。很高兴看到你继续前进。
 
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-8-18 22:41 , Processed in 1.545503 second(s), 73 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表