gzxl 发表于 2013-6-15 00:03:09

本帖最后由 gzxl 于 2013-6-15 07:29 编辑

hnlgy 发表于 2013-6-14 20:07 http://bbs.mjtd.com/static/image/common/back.gif
顶起来让大家看见,别沉了。

是不是这样的?先发个测试的fas,如是这样再奉上代码


hnlgy 发表于 2013-6-15 07:38:31

gzxl 发表于 2013-6-15 00:03 static/image/common/back.gif
是不是这样的?先发个测试的fas,如是这样再奉上代码

感谢分享,正是需要这种效果。

ucuc2003 发表于 2013-6-15 11:15:47

http://bbs.mjtd.com/thread-91647-1-1.html
看下yjr111 老大的作品,这个很不错

阿然 发表于 2013-6-15 15:16:14

多行文字的实际高宽请参考组码42及43,给你一个cab大师的多行文字boundingbox的代码

(defun box_mtext (ent / elst p10 txth ang vec wid hgt dxf UCSangle
                  attpt ul ur lr ll)
(defun dxf (code elst)
    (cdr (assoc code elst))
)

;; incase it is a list,(ename point)
(and (listp ent) (setq ent (car ent)))
(setq elst (entget ent))

(setq p10   (trans (dxf 10 elst) 0 1) ; insertion point WCS to UCS
      txth(dxf 40 elst) ; text height
      wid   (dxf 42 elst) ; full width
      hgt   (dxf 43 elst) ; full height
      ang   (dxf 50 elst) ; rotation angle in UCS
      attpt (dxf 71 elst) ; attachment point code
)

;|--------------------------------------------------------------
;;CAB 01/24/2006 removed as the ang fron DXF code 50 os in UCS
;;correct for UCS
(setqang (- ang (angle (trans '(0.0 0.0 0.0) 1 0)
                           (trans '(1.0 0.0 0.0) 1 0)))
)
;;angles90 = (/ pi 2)   180 = pi270 = (* pi 1.5)
---------------------------------------------------------------|;


;;Get upper left (ul) from insert point (p10)
(cond ((= attpt 1) (setq ul p10)) ; top left
      ((= attpt 2) (setq ul (polar p10 (+ pi ang) (/ wid 2)))) ; top center
      ((= attpt 3) (setq ul(polar p10 (+ pi ang) wid))) ; top right
      ((= attpt 4) (setq ul (polar p10 (+ (/ pi 2) ang) (/ hgt 2)))) ; middle left
      ((= attpt 5) ; middle center
         (setq ul (polar (polar p10 (+ pi ang) (/ wid 2)) (+ (/ pi 2) ang) (+ (/ hgt 2)))))
      ((= attpt 6) ; middle right
         (setq ul (polar (polar p10 (+ pi ang) wid) (+ (/ pi 2) ang) (+ (/ hgt 2)))))
      ((= attpt 7) (setq ul (polar p10 (+(/ pi 2) ang) hgt))) ; bottom left
      ((= attpt 8) ; bottom center
         (setq ul (polar (polar p10 (+ pi ang) (/ wid 2)) (+ (/ pi 2) ang) hgt)))
      ((= attpt 9) ; bottom right
         (setq ul (polar (polar p10 (+ pi ang) wid) (+ (/ pi 2) ang) hgt)))
);cond
(setq ur (polar ul ang wid)
      lr (polar ur (+ ang (* pi 1.5)) hgt)
      ll (polar lr (+ ang pi) wid)
);setq
(list ll lr ur ul)
);boxmtext

hnlgy 发表于 2013-6-15 16:16:05

多谢楼上两位的回复,仔细消化代码。

669423907 发表于 2013-6-18 08:51:27

gzxl 发表于 2013-6-15 00:03 static/image/common/back.gif
是不是这样的?先发个测试的fas,如是这样再奉上代码

G版您好,这种效果很好啊,不知道方不方便把对象居中的和你的整合一下,当选择对象为非文字时,调用对象居中,当选择对象为文字时就调用文字居中,这样的效果是不是更好呢?

陈亚娣 发表于 2013-6-18 16:25:52

Qwer1243 发表于 2022-2-20 08:34:17

gzxl 发表于 2013-6-15 00:03
是不是这样的?先发个测试的fas,如是这样再奉上代码

大佬 能发一下这个文本居中的源码 学习一下吗
页: 1 [2]
查看完整版本: 再次求助高手们完善下面这个封闭区域内文本居中小程序