- 积分
- 15341
- 明经币
- 个
- 注册时间
- 2002-2-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-3-10 08:36:00
|
显示全部楼层
文字的插入点不好框選,而且文字的插入点可隨便改變,程序...
本帖最后由 作者 于 2003-3-10 8:36:41 编辑
;;文字到直线垂距5范围内的文字,这句话有点不清楚
;;垂距的定义是甚么??是文字插入点吗?
;;文字插入点可不大好处理!!!
;;框选文字本身程序如下!!!
;;USAGETT <范围>)
;;USAGETT 5)
(defun TT (D / FF GG AA CURRENT_LINE QQ PT1 PT2)
(command "_.undo" "group")
(command "_.zoom" "e")
(setq FF (findfile "数据文件.TXT"))
(setq GG (open (strcat (vl-filename-directory FF) "\\生成檔.TXT")
"w"
)
)
(write-line "标号 距离 读数" GG)
(if (setq FF (open FF "r"))
(progn
(setq CURRENT_LINE (read-line FF))
(while (setq CURRENT_LINE (read-line FF))
(setq AA (PARSE CURRENT_LINE ","))
(setq PT1 (list (read (nth 1 AA)) (read (nth 2 AA))))
(setq PT2 (list (read (nth 3 AA)) (read (nth 4 AA))))
(if (/= (cadr PT1) (cadr PT2))
(setq QQ (vl-sort (list PT1 PT2)
(function (lambda (P1 P2)
(> (cadr P1) (cadr P2))
)
)
)
)
(setq QQ (vl-sort (list PT1 PT2)
(function (lambda (P1 P2)
(< (car P1) (car P2))
)
)
)
)
)
(command
"_.line"
(car QQ)
(cadr QQ)
""
)
(TTT (entlast) D)
(command "text"
"j"
"m"
(polar (car QQ) (angle (cadr QQ) (car QQ)) 5)
"5"
""
(nth 0 AA)
)
)
)
)
(close FF)
(close GG)
(command "_.zoom" "p")
(command "_.undo" "end")
(print)
)
(defun PARSE (STR DELIM / LST POS)
(setq POS (vl-string-search DELIM STR))
(while POS
(setq LST (cons (substr STR 1 POS) LST)
STR (substr STR (+ POS 2))
POS (vl-string-search DELIM STR)
)
)
(if (> (strlen STR) 0)
(setq LST (cons STR LST))
)
(reverse LST)
)
(defun TTT (ENT1 D / HOLDOSMODE QQQ ENT ENTANG SS)
;;摘取靠近直线一定范围内的文字
(defun SET_BOX (ENT1 D / ENT10 ENT11 ENTDIST PT1 PT2 PT3 PT4 SS)
(setq _PI2 (/ pi 2.0))
(setq ENT10 (DXF 10 ENT1))
(setq ENT11 (DXF 11 ENT1))
(setq ENTANG (angle ENT10 ENT11))
(setq ENTDIST (distance ENT10 ENT11))
(setq PT1 (polar ENT10 (+ _PI2 ENTANG) D))
(setq PT2 (polar PT1 ENTANG ENTDIST))
(setq PT3 (polar PT2 (- ENTANG _PI2) (* D 2.0)))
(setq PT4 (polar ENT10 (- ENTANG _PI2) D))
(setq SS (ssget "cp" (list PT1 PT2 PT3 PT4) '((0 . "text"))))
SS
)
(defun DXF (A1 A2)
(cdr (assoc A1 (entget A2)))
)
;;文字插入点与直线最近点
(defun PTLIST (SS ENT1 / PP PLIST N)
(setq ENT1 (vlax-ename->vla-object ENT1))
(setq N 0)
(repeat (sslength SS)
(setq ENT (vlax-ename->vla-object (ssname SS N)))
(setq PP (vlax-safearray->list
(vlax-variant-value
(vla-get-insertionpoint ENT)
)
)
)
(setq PLIST (append PLIST
(list (list (vlax-curve-getclosestpointto
ENT1
PP
)
(vla-get-textstring ENT)
)
)
)
)
(setq N (1+ N))
)
PLIST
)
(setq HOLDOSMODE (getvar "osmode"))
(setvar "osmode" 0)
(if (setq SS (SET_BOX ENT1 D))
(progn
(if (/= (cadr PT1) (cadr PT2))
(setq
QQQ (reverse (vl-sort (PTLIST SS ENT1)
(function (lambda (P1 P2)
(< (cadar P1) (cadar P2))
)
)
)
)
)
(setq
QQQ (vl-sort (PTLIST SS ENT1)
(function (lambda (P1 P2)
(< (cadar P1) (cadar P2))
)
)
)
)
)
;;写出档案
;;----------------------------------------------
(write-line
(strcat (nth 0 AA)
" "
(rtos (distance (car QQ) (car (nth 0 QQQ))) 2 2)
" "
(cadr (nth 0 QQQ))
)
GG
)
(setq N 1)
(repeat (- (length QQQ) 1)
(write-line
(strcat " "
(rtos (distance (car QQ) (car (nth N QQQ))) 2 2)
" "
(cadr (nth N QQQ))
)
GG
)
(setq N (1+ N))
)
;;------------------------------------------------
;|
;;尺寸标注
;;------------------------------------------------
(command "_.dimaligned"
(car QQ)
(car (nth 0 QQQ))
(polar (car QQ) (+ _PI2 ENTANG) (* D 2.0))
)
(command "_.dimbaseline")
(setq QQQ (cdr QQQ))
(setq N 0)
(repeat (length QQQ)
(command (car (nth N QQQ)))
(setq N (1+ N))
)
(command)
|;
;;-------------------------------------------------
)
)
(setvar "osmode" HOLDOSMODE)
(princ)
) |
|