明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 725|回复: 15

多行文字每行画下划线

[复制链接]
发表于 2023-11-13 11:59 | 显示全部楼层 |阅读模式
  1. (defun c:wws(/ en wz wz1 )
  2.   (setq en (entget (car(entsel))))
  3.   (setq wz (cdr (assoc 1 en )))

  4.   (setq wz1 (strcat "{\\L" wz "}"))
  5.   (setq en (subst (cons 1 wz1)  (cons 1 wz)  en))
  6.   (entmod en)
  7.   (prin1)
  8. )

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2023-11-13 13:44 | 显示全部楼层
  1. (defun c:wwe ()
  2.   (setq sh (getvar "peditaccept"))
  3.   (setvar "peditaccept" 0)
  4.   (setq osm (getvar "osmode"))
  5.   (setvar "osmode" 0)
  6.   ;(setq mclayer (getvar "CLAYER"))
  7.   ;(setvar "CLAYER" "0")
  8.   (setq ss1 (ssget '((0 . "*TEXT"))))
  9.   (if (null ss1)
  10.     (progn
  11.       (princ "\n没有文本实体被选择!")
  12.       (exit)
  13.     )                                       ; end progn
  14.   )                                       ; end if
  15.   (setq n (sslength ss1))
  16.   (if (not (= nil n))                       ; no select objects
  17.     (progn
  18.     (setq i 0)
  19.     (while (< i n)
  20.         (setq txtentname (ssname ss1 i))
  21.         (setq txtentdata (entget txtentname))
  22.         (setq i (+ i 1))
  23.         (setq txtenttype (cdr (assoc 0 txtentdata))) ; get entity's name:
  24.                                        ; "text" or "mtext"
  25.         (if (= txtenttype "TEXT")      ; this object is simple line text
  26.           (progn
  27.             (vl-cmdf "ucs" "Object" txtentname)        ; 定义用户坐标系到文本的方?
  28.             (setq tbox (textbox (list (car txtentdata))) ; must change to a list
  29.                       pt_bl (car tbox)     ; left bottom point coords
  30.                       pttr (cadr tbox)     ; right top point coords
  31.                       pttl (list (car pt_bl) (cadr pttr))
  32.                       pt_br (list (car pttr) (cadr pt_bl))
  33.             )                               ; end setq
  34.             (setq roundspace (* 0.2 (distance pt_bl pttl)))
  35.             (setq pt_bl (polar pt_bl pi (* roundspace 2)))
  36.             (setq pt_bl (polar pt_bl (* pi 1.5) roundspace))
  37.             (setq pt_br (polar pt_br 0.0 (* roundspace 2)))
  38.             (setq pt_br (polar pt_br (* pi 1.5) roundspace)) ;
  39.             ;(command "pline" pt_bl "w" (* roundspace 0.25) "" pt_br "" "")
  40.             ;(command "CHPROP" (entlast) "" "C" "BYBlock" "")
  41.             (command "pline" (polar pt_bl (* pi 1.5) (* roundspace 0.6)) "w" 0 "" (polar pt_br (* pi 1.5) (* roundspace 0.6)) "")
  42.           (command "CHPROP" (entlast) "" "C" "240" "")               
  43.             (setvar "peditaccept" sh)
  44.             (vl-cmdf "ucs" "p" "")
  45.           )                               ; end progn
  46.           (progn
  47.             (vl-cmdf "_.JustifyText" txtentname "" "TL") ; 处理为对对齐模式.
  48.             (setq txtentdata (entget txtentname))
  49.             (setq pttl (cdr (assoc 10 txtentdata))
  50.                   xwidth (cdr (assoc 42 txtentdata))
  51.                   xheight (cdr (assoc 43 txtentdata))
  52.                   xangle (cdr (assoc 50 txtentdata))
  53.                   pt_tc (polar pttl xangle (* xwidth 0.5))
  54.                   pttr (polar pttl xangle xwidth)
  55.                   pt_bl (polar pttl (- xangle (/ pi 2.0)) xheight)
  56.                   pt_bc (polar pt_bl xangle (* xwidth 0.5))
  57.                   pt_br (polar pt_bl xangle xwidth)
  58.                   pt_mc (polar pt_bl (angle pt_bl pttr) (/
  59.                                                            (distance pt_bl
  60.                                                                      pttr
  61.                                                            ) 2.0 ; end
  62.                                                         ) ; end angle
  63.                         )               ; end polar
  64.             )                               ; end setq
  65.             (setq roundspace (* 0.2 (distance pt_bl pttl)))
  66.             (setq xangle (cdr (assoc 50 txtentdata)))
  67.             (setq pt_bl (polar pt_bl xangle (- roundspace)))
  68.             (setq pt_bl (polar pt_bl (+ xangle (/ pi 2.0)) (- roundspace)))
  69.             (setq pt_br (polar pt_br xangle roundspace))
  70.             (setq pt_br (polar pt_br (+ xangle (/ pi 2.0)) (- roundspace)))
  71.             (setq pttl (polar pttl xangle (- roundspace)))
  72.             (setq pttl (polar pttl (+ xangle (/ pi 2.0)) roundspace))
  73.             (setq pttr (polar pttr xangle roundspace))
  74.             (setq pttr (polar pttr (+ xangle (/ pi 2.0)) roundspace)) ;
  75.             ;(command "pline" pt_bl "w" (* roundspace 0.25) "" pt_br "")
  76.             ;(command "CHPROP" (entlast) "" "C" "BYBlock" "")
  77.             (command "pline" (polar pt_bl (* pi 1.5) (* roundspace 0.6)) "w" 0 "" (polar pt_br (* pi 1.5) (* roundspace 0.6)) "")
  78.          (command "CHPROP" (entlast) "" "C" "240" "")                               ; end command
  79.             (setvar "peditaccept" sh)
  80.           )                               ; end progn
  81.         )                               ; end if
  82.       )                                       ; end while
  83.     )                                       ; end progn
  84.   )                                       ; end if
  85.   (setvar "CLAYER" mclayer)
  86.   (vl-cmdf "ucs" "W" "")
  87.   (setvar "osmode" osm)
  88.   (princ)
  89. )


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2023-11-16 17:06 | 显示全部楼层
自贡黄明儒 发表于 2023-11-14 07:11
好像langjs大师写过,你找一下他的帖子
http://www.mjtd.com/home.php?mod=space&uid=52147&do=thread&vie ...

http://bbs.mjtd.com/thread-84999-1-1.html?_dsign=8d0395fc
大师,能帮忙整一下吗?
 楼主| 发表于 2023-11-13 15:58 | 显示全部楼层
黄大师,还有看到你的文字穿的函数,有没从中间取出字符串的函数。substr试了下乱码。
现在有了多行文字加下划线,取掉下划线的时候,处理有问题,能帮忙看下?
U这种加减下划线的是不是有快捷键?比较乱,希望大师赐教
发表于 2023-11-13 15:37 | 显示全部楼层
桌子只有一根下划线,你要2两根,只好用直线了。
 楼主| 发表于 2023-11-13 15:53 | 显示全部楼层
多谢,是要直线,后面那个长代码只能适用多行文字为一行的情况,有没类似的代码或者函数发下参考下?
发表于 2023-11-13 16:58 | 显示全部楼层
这是我一个QQ版的,把插件上传,看谁能破了。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2023-11-13 17:11 | 显示全部楼层
wangsr 发表于 2023-11-13 16:58
这是我一个QQ版的,把插件上传,看谁能破了。

这个长代码就可以实现,里面有两个画线的命令,问题是多行文字多尴行数时候,每一行怎么都画直线?
发表于 2023-11-14 07:11 | 显示全部楼层
好像langjs大师写过,你找一下他的帖子
http://www.mjtd.com/home.php?mod ... om=space&page=2
 楼主| 发表于 2023-11-14 12:47 | 显示全部楼层
多行文本处理是炸开了变成单行了,大师不用炸开,还是需要多行文本的怎么处理?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-3 00:14 , Processed in 0.468505 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表