半听可乐 发表于 2012-7-13 11:36:47

谁有交换单行文字内容的程序?

具体要求:交换单行文字内容以及文字的所有属性

hao3ren 发表于 2012-7-13 11:36:48

(defun C:hh (/ a b a1 b1)
(setq a (entsel "\n选择第一个文本"))
(setq b (entsel "\n选择第二个文本"))
(setq a1 (cdr (assoc 10 (entget (car a)))))
(setq b1 (cdr (assoc 10 (entget (car b)))))
(command "move" a "" a1 b1)
(command "move" b "" b1 a1)
(princ)
)

hao3ren 发表于 2012-7-13 12:36:57

(defun C:hh (/ a b a1 b1)
(setq a (entget (car (entsel "\n选择第一个文本"))))
(setq b (entget (car (entsel "\n选择第二个文本"))))
(setq a1 (cdr (assoc 1 a)))
(setq b1 (cdr (assoc 1 b)))

(setq        a (SUBST (cons 1 b1)
               (ASSOC 1 a)
               a

          )
)
(setq        b (SUBST (cons 1 a1)
               (ASSOC 1 b)
               b
          )
)

(ENTMOD a)
(ENTMOD b)
(princ)
)

半听可乐 发表于 2012-7-13 13:13:20

本帖最后由 半听可乐 于 2012-7-13 13:13 编辑

hao3ren 发表于 2012-7-13 12:36 http://bbs.mjtd.com/static/image/common/back.gif
(defun C:hh (/ a b a1 b1)
(setq a (entget (car (entsel "\n选择第一个文本"))))
(setq b (entget...

只能换内容,文字样式、图层等信息不能交换吗?

xyp1964 发表于 2012-7-13 13:39:41

直接相互移动交换位置

vormittag 发表于 2012-7-13 14:04:18

呵呵,院长的解答是最好的。

半听可乐 发表于 2012-7-13 15:37:19

xyp1964 发表于 2012-7-13 13:39 static/image/common/back.gif
直接相互移动交换位置

怎么实现呢?

半听可乐 发表于 2012-7-13 17:09:06

感谢好人兄!程序很好用

xyp1964 发表于 2012-7-13 18:54:34

;; 交换单行文字内容 伪源码需要e派工具箱(XCAD)的支持
(defun c:tt ()
(if (and (setq s1 (car (entsel "\n选择第1个文本: ")))
           (setq s2 (car (entsel "\n选择第2个文本: ")))
           (not (equal s1 s2))
           (xyp-etype s1 "text")
           (xyp-etype s2 "text")
      )
    (progn
      (setq p1 (xyp-get-9pt s1 1)
          p2 (xyp-get-9pt s2 1)
      )
      (xyp-move s1 p1 p2)
      (xyp-move s2 p2 p1)
    )
)
(princ)
)

tianyi1230 发表于 2012-7-14 20:32:22

院长的是伪源码啊
页: [1] 2
查看完整版本: 谁有交换单行文字内容的程序?