找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 977|回复: 1

[他山之石] 反应器实例-Pline长宽文字

[复制链接]

已领礼包: 264个

财富等级: 日进斗金

发表于 2016-12-12 17:35:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×

  1. (defun !last (lst)
  2.   (reverse (cdr (reverse lst)))
  3. )
  4. (defun make-same-pline-txt (obj1 obj2)
  5.   (defun chg_pline_link_txt (v1 / p1 p2 p3 w h txt)
  6.     (setq txt (vlax-ldata-get v1 "Link"))
  7.     (if        (not (vlax-erased-p txt))
  8.       (progn
  9.         (setq p1 (vlax-curve-getpointatparam v1 0.)
  10.               p2 (vlax-curve-getpointatparam v1 1.)
  11.               p3 (vlax-curve-getpointatparam v1 2.)
  12.               w         (fix (distance p1 p2))
  13.               h         (fix (distance p2 p3))
  14.         )
  15.         (vl-catch-all-apply
  16.           'vla-put-textstring
  17.           (list        txt
  18.                 (strcat (itoa w) "X" (itoa h))
  19.           )
  20.         )
  21.       )
  22.     )
  23.   )
  24.   (defun chg_txt_link_pline (v1 / sp p1 p2 p3 str pos w h pts)
  25.     (setq pl (vlax-ldata-get v1 "Link"))
  26.     (if        (not (vlax-erased-p pl))
  27.       (progn
  28.         (setq sp  (vlax-curve-getstartpoint pl)
  29.               p1  (vlax-curve-getpointatparam pl 1.)
  30.               p2  (vlax-curve-getpointatparam pl 2.)
  31.               p3  (vlax-curve-getpointatparam pl 3.)
  32.               str (vla-get-textstring v1)
  33.               pos (vl-string-position (ascii "X") str)
  34.               w          (distof (substr str 1 pos))
  35.               h          (distof (substr str (+ pos 2)))
  36.         )
  37.         (vla-put-coordinates
  38.           pl
  39.           (vlax-make-variant
  40.             (vlax-safearray-fill
  41.               (vlax-make-safearray vlax-vbDouble '(0 . 7))
  42.               (apply 'append
  43.                      (list (!last sp)
  44.                            (setq p11 (polar (!last sp) (angle sp p1) w))
  45.                            (setq p22 (polar p11 (angle p1 p2) h))
  46.                            (polar p22 (angle p2 p3) w)
  47.                      )
  48.               )
  49.             )
  50.           )
  51.         )
  52.         (vla-put-closed pl actrue)
  53.       )
  54.     )
  55.   )
  56.   (if (and
  57.         obj2
  58.         (vlax-write-enabled-p obj2)
  59.         (vlax-read-enabled-p obj1)
  60.       )
  61.     (if        (= (vla-get-objectname obj1) "AcDbText")
  62.       (chg_txt_link_pline obj1)
  63.       (chg_pline_link_txt obj1)
  64.     )
  65.   )
  66. )
  67. (defun make-same-pline-txt-reaction (notifier reactor arg-list)
  68.   (make-same-pline-txt notifier (VLR-Data reactor))
  69. )
  70. (defun c:tt (/ e1 e2 obj1 obj2)
  71.   (if (and (setq e1 (car (entsel "\nPick Pline: ")))
  72.            (setq e2 (car (entsel "\nSelect associated text: ")))
  73.       )
  74.     (progn
  75.       (vlax-ldata-put
  76.         e1
  77.         "Link"
  78.         (setq obj2 (vlax-ename->vla-object e2))
  79.       )
  80.       (vlax-ldata-put
  81.         e2
  82.         "Link"
  83.         (setq obj1 (vlax-ename->vla-object e1))
  84.       )
  85.       (setq myReactor
  86.              (vlr-object-reactor
  87.                (list obj2)
  88.                obj1
  89.                '((:vlr-modified . make-same-pline-txt-reaction))
  90.              )
  91.       )
  92.       (setq TxtReactor
  93.              (vlr-object-reactor
  94.                (list obj1)
  95.                obj2
  96.                '((:vlr-modified . make-same-pline-txt-reaction))
  97.              )
  98.       )
  99.     )
  100.   )
  101.   (princ)
  102. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 19个

财富等级: 恭喜发财

发表于 2016-12-12 17:47:50 | 显示全部楼层
执行TT后,选择文字后,没有把文字变成长X宽, 只有编辑下矩形,文字才跟着变化。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-29 00:59 , Processed in 0.237949 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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