明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 573|回复: 9

单行文本动态伸缩

[复制链接]
发表于 2024-7-4 14:22:49 | 显示全部楼层 |阅读模式
本帖最后由 尘缘一生 于 2024-7-4 14:38 编辑

这个就不用解释了,然不同是什么呢?我不知道才发帖,你不知道请你闭嘴,别回复,下载。




三领设计 V3.0 永久下载地址:

链接:https://pan.baidu.com/s/1WsH2nmBHUhb0T3STais1Hg
提取码:i2uj

本帖子中包含更多资源

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

x

评分

参与人数 2明经币 +2 收起 理由
hubeiwdlue + 1 很给力!
tranque + 1 赞一个!

查看全部评分

发表于 2024-7-4 16:01:29 | 显示全部楼层
不错,代码简练,不过运行出现“参数太少”,楼主检查一下
 楼主| 发表于 2024-7-4 16:24:45 | 显示全部楼层
本帖最后由 尘缘一生 于 2024-7-4 16:38 编辑
bai2000 发表于 2024-7-4 16:01
不错,代码简练,不过运行出现“参数太少”,楼主检查一下

不会吧?等我完善看看,刚刚换成函数做法,比较下子
  1. ;根据 lstSub 子表中的首元素 替换 lstSource 中对应表元-----(一级)--------
  2. ;lstSub需要替换的列表   lstSource源列表   bAdd是否向源列表中追加 原本没有的元素
  3. (defun sl:list-substassoc (lstSub  lstSource  bAdd / e e1)
  4.   (foreach e lstSub
  5.     (if (setq e1 (assoc (car e) lstSource))
  6.       (setq lstSource (subst e (assoc (car e) lstSource) lstSource))
  7.       (if bAdd (setq lstSource (append lstSource (list e))))
  8.     )
  9.   )
  10.   lstSource
  11. )
  12. ;原位修改文字对齐方式---(一级)----
  13. ;注:代码出处 "信.工具箱"  Modify by 尘缘一生  QQ:15290049 2024.7.4
  14. (defun text:alignmod (nam mode / p10 p11 ent box b ang)
  15.   (setq ent (entget nam))
  16.   (setq p10 (dxf1 ent 10))
  17.   (setq b (cadr (textbox ent)))
  18.   (setq ang (dxf1 ent 50))
  19.   (setq ent
  20.     (entmod
  21.       (cond
  22.         ((= (strcase mode) "L") ;左对齐
  23.           (sl:list-substassoc (list (cons 10 p10) '(72 . 0) '(73 . 0)) ent t)
  24.         )
  25.         ((= (strcase mode) "C") ;中对齐
  26.           (sl:list-substassoc (list (cons 11 p10) '(72 . 1) '(73 . 0)) ent t)
  27.         )
  28.         ((= (strcase mode) "R") ;右对齐
  29.           (sl:list-substassoc (list (cons 11 p10) '(72 . 2) '(73 . 0)) ent t)
  30.         )
  31.         ((= (strcase mode) "M") ;中心对齐
  32.           (sl:list-substassoc (list (cons 11 p10) '(72 . 4) '(73 . 0)) ent t)
  33.         )
  34.         ((= (strcase mode) "A") ;对齐
  35.           (setq p11 (polar p10 ang (car b)))
  36.           (sl:list-substassoc (list (cons 10 p10) (cons 11 p11) '(72 . 3) '(73 . 0)) ent t)
  37.         )
  38.         ((= (strcase mode) "F") ;调整
  39.           (setq p11 (polar p10 ang (car b)))
  40.           (sl:list-substassoc (list (cons 10 p10) (cons 11 p11) '(72 . 5) '(73 . 0)) ent t)
  41.         )
  42.         ((= (strcase mode) "BL") ;左下
  43.           (sl:list-substassoc (list (cons 11 p10) '(72 . 0) '(73 . 1)) ent t)
  44.         )
  45.         ((= (strcase mode) "BC") ;中下
  46.           (sl:list-substassoc (list (cons 11 p10) '(72 . 1) '(73 . 1)) ent t)
  47.         )
  48.         ((= (strcase mode) "BR") ;右下
  49.           (sl:list-substassoc (list (cons 11 p10) '(72 . 2) '(73 . 1)) ent t)
  50.         )
  51.         ((= (strcase mode) "ML") ;左中
  52.           (sl:list-substassoc (list (cons 11 p10) '(72 . 0) '(73 . 2)) ent t)
  53.         )
  54.         ((= (strcase mode) "MC") ;正中
  55.           (sl:list-substassoc (list (cons 11 p10) '(72 . 1) '(73 . 2)) ent t)
  56.         )
  57.         ((= (strcase mode) "MR") ;右中
  58.           (sl:list-substassoc (list (cons 11 p10) '(72 . 2) '(73 . 2)) ent t)
  59.         )
  60.         ((= (strcase mode) "tL") ;左上
  61.           (sl:list-substassoc (list (cons 11 p10) '(72 . 0) '(73 . 3)) ent t)
  62.         )
  63.         ((= (strcase mode) "tC") ;中上
  64.           (sl:list-substassoc (list (cons 11 p10) '(72 . 1) '(73 . 3)) ent t)
  65.         )
  66.         ((= (strcase mode) "tR") ;右上
  67.           (sl:list-substassoc (list (cons 11 p10) '(72 . 2) '(73 . 3)) ent t)
  68.         )
  69.         (t ent)
  70.       )
  71.     )
  72.   )
  73.   (setq ent (entget (dxf1 ent -1)))
  74.   (setq p11 (mapcar '+ (mapcar '- p10 (dxf1 ent 10)) (dxf1 ent 11)))
  75.   (entmod (sl:list-substassoc (list (cons 10 p10) (cons 11 p11)) ent t))
  76. )
  77. ;;单行TEXT文本选择集-动态拉伸---(一级)----
  78. ;;功能 程序去除文字的前面空格,后面的空格,进行动态伸缩,保持角度,定位点不变
  79. ;三领设计 V3.0 Modify by 尘缘一生  QQ:15290049 2024.7.4  (精简后代码)
  80. (defun macedit-text (ss / pt gr loop enam n i ang ent tx p p1)
  81.   (defun sskk (ss pt)
  82.     (repeat (setq n (sslength ss))
  83.       (setq enam (ssname ss (setq n (1- n))))
  84.       (setq ent (entget enam) p (dxf1 ent 10) tx (dxf1 ent 1) ang (dxf1 ent 50) p1 (polar p ang 300.0))
  85.       (while (= (substr tx 1 1) " ") ;文字前去空格
  86.         (setq tx (substr tx 2))
  87.       )
  88.       (setq i (strlen tx))
  89.       (while (= (substr tx i 1) " ");文字后去空格
  90.         (setq tx (substr tx 1 (1- i)) i  (strlen tx))
  91.       )
  92.       (entmod (emod (emod (emod (emod ent 1 tx) 11 (pertolinecz pt p p1)) 72 5) 73 0)) ;变F(双穴点)定位,去前后空格,确保右侧对齐光标点
  93.       ;(if (if-color) (vla-put-color (en2obj enam) (atoi (slsjqs)))) ;此为三领集成,变色系统,可忽略
  94.     )
  95.   )
  96.   ;;-----------------
  97.   (princ"\n 动态拉伸>>>:")
  98.   (setq loop t)
  99.   (while loop
  100.     (setq gr (grread t 15 0) pt (cadr gr))
  101.     (cond
  102.       ((= (car gr) 5)
  103.         (sskk ss pt)
  104.       )
  105.       ((member (car gr) '(3 11 25))  ;;左键 右键
  106.         (setq loop nil)
  107.       )
  108.     )
  109.   )
  110.   (while (setq enam (ssname ss 0)) ;等同于(vl-cmdf "_.JustifyText" ss "" "L")
  111.     (text:alignmod enam "L")
  112.     (ssdel enam ss)
  113.   )
  114.   (princ)
  115. )


发表于 2024-7-4 18:13:54 | 显示全部楼层
陈总威武啊,
发表于 2024-7-16 22:40:43 | 显示全部楼层
这个挺不错的哈
发表于 2024-7-21 14:53:01 | 显示全部楼层
好東西,謝謝分享,感謝!!!
发表于 2024-7-21 15:53:03 | 显示全部楼层
Thanks for sharing
发表于 2024-7-24 09:49:28 | 显示全部楼层
好東西,謝謝分享,感謝!!!
发表于 2024-7-30 16:41:11 来自手机 | 显示全部楼层
感谢分享,很实用
发表于 2024-7-30 17:15:37 | 显示全部楼层
不知道启动命令
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-8 08:52 , Processed in 0.162964 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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