本帖最后由 springwillow 于 2013-1-29 18:37 编辑
ynhh 发表于 2013-1-27 17:24
感谢大师的热心指点.
你说的很有道理
看看吧,是不是这样- (defun zcx()
- (setvar "osmode" 0)
- ;(setq p2 (getpoint P1 "\n-->请指定文字位置:")
- (setq p2 (polar p1 0 10)
- a1 (car p1 )
- c1 (car p2)
- vx (* (- (strlen TXT) 0.2) (* ht 0.75))
- le vx
- )
- (if (< c1 a1)
- (setq pp (polar p2 pi le)
- p3 (polar pp (/ pi 2) zj)
- )
- (setq pp (polar p2 0 le)
- p3 (polar p2 (/ pi 2) zj)
- ))
- (setq en1 (HDX (list (setq p11 (polar p1 0 0.1)) p2 PP) 0.1))
- ;(command "line" p2 pp "")
- ;(setq en2 (entlast))
-
- ;;;请教大师:我想到两根直线合并为一根带线宽的多线,但不知如何实现动态更新?有此功能吗?如有请教方法,感谢你。
- (setq XK 0.3);设置线宽
- (setq en20 (HDX (list p1 PP) XK));画带线宽的多线)
-
- ;;; (command "text" P3 ht 0 TXT)
- (command "TEXT" "J" "ML" P3 ht "0" TXT);----画样式写入文字
- (setq en3 (entlast));entlast 返回最后一个未删除的主图元名。
- (setq ent1 (entget en1); entget 此函数将由数据库中取出 ename 的图元, 同时返回一表
- ;ent2 (entget en2)
- ent3 (entget en3))
- (setq le1 (caadr (textbox ent3))); textbox 这个函数将计算一个文字图元并返回包围文字的交互坐标框。
- (setq le (* 1.2 le1)
- jl (* 0.1 le1))
- ;;|;;
- (while (= (car (setq mouse (grread t 0 0))) 5)
- (setq pt (cadr mouse))
-
- (if (>= (car pt)(car p1))
- (progn
- ;以下句子可自行简写
- (setq pt (polar pt 0 1))
- (setq pt (trans pt 1 0))
- (setq ent1 (subst (cons 10 (3D->2D pt))(cons 10 (3D->2D p2)) ent1))
- (setq p2 pt)
- (setq ent1 (subst (cons 10 (3D->2D(trans (polar pt 0 le) 1 0)))(cons 10 (3D->2D pp)) ent1))
- (setq pp (trans (polar (trans pt 0 1) 0 le) 1 0))
- (setq ent1 (subst (cons 10 (3D->2D p1))(cons 10 (3D->2D p11)) ent1))
- ; subst 此函数将在 list 寻找所给定的 olditem, 然后再依据所给定的 newitem 来取代每一个 olditem。但当找不到 list 中的 olditem 时, 此函数将返回原有的 list。
- ;cons 它是“构造”(construct) 表的最基本函数, 它将一个元素 (new-first-element) 与一个表 (list) 接合起来, 并返回以此新元素为首的新表。
- ;assoc 此函数将在联合表 (association list) alist 中搜寻以item 为名称的对应值, 如果找到, 则 assoc 会返回其对应值。若找不到, 则会返回 nil。
- (entmod ent1); entmod 函数来更新数据库内的图元。
- (setq ent3 (subst '(72 . 0) (assoc 72 ent3) ent3))
- (setq ent3 (subst (cons 10 (list (+ (car pt) jl) (+ (cadr pt) zj)))(assoc 10 ent3) ent3))
- (setq ent3 (subst (cons 11 (list (+ (car pt) jl) (+ (cadr pt) zj)))(assoc 11 ent3) ent3))
- (entmod ent3)
- )
- (progn
- (setq pt (trans pt 1 0))
- (setq ent1 (subst (cons 10 (3D->2D pt))(cons 10 (3D->2D p2)) ent1))
- (setq p2 pt)
- (setq ent1 (subst (cons 10 (3D->2D (trans (polar (trans pt 0 1) PI le) 1 0)))(cons 10 (3D->2D pp)) ent1))
- (setq pp (trans (polar (trans pt 0 1) PI le) 1 0))
- (entmod ent1)
- (setq ent3 (subst '(72 . 2) (assoc 72 ent3) ent3))
- (setq ent3 (subst (cons 10 (list (- (car pt) jl) (+ (cadr pt) zj)))(assoc 10 ent3) ent3))
- (setq ent3 (subst (cons 11 (list (- (car pt) jl) (+ (cadr pt) zj)))(assoc 11 ent3) ent3))
- (entmod ent3)
- )
- )
- );while
- ;;|;;
- (princ)
- )
- (defun c:A ()
- (setq AA (getvar "clayer"))
- (setq layer "文字 text")(if (not (tblsearch "layer" layer ))
- (progn (command "layer" "new" "文字 text" "s" "文字 text" "C" 212 "" "L" "Continuous" "" "LW" 0.2 "" "")
- ))
- (COMMAND "CLAYER" layer)
- (setvar "texteval" 1)
- (setvar "cmdecho" 0)
- (setq vv (getvar "osmode"))
- ;;; (setq ht (getreal "\n-->标注字高:(默认:2.5)"))
- (setq ht 3);暂用固定练习
- (if (= ht nil) (setq ht 2.5))
- (setq zj (/ ht 3))
- (setq n 0)
- (while (= n 0)
- ;;; (setq TXT (getstring "\n-->请输入文字:"))
- (setq TXT "操作练习");暂用固定练习
- (setvar "osmode" 33)
- (if (/= txt "")
- (setq p1 (getpoint "\n-->请指定点坐标:")
- )
- )
- (if (= txt "") (setq n 1)(zcx))
- )
- (setvar "osmode" vv)
- (princ)
- )
- ;;;以下是一个找来的用图元方法画多线,但不知如何在动态中更新,也请大师指点
- (defun HDX (pts XK)
- (if (entmake
- (append (list '(0 . "LWPOLYLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbPolyline")
- (cons 90 (length pts))
- (cons 43 xk)
- )
- (mapcar '(lambda (x) (cons 10 (trans x 1 0))) pts)
- '((210 0. 0. 1.))
- )
- )
- (entlast)
- )
- )
- (defun 3D->2D (p /)
- (list (car p)(cadr p))
- )
|