本帖最后由 ww5w 于 2013-2-5 14:16 编辑
xiabin68 发表于 2013-2-5 10:15
把你的代码帖出来,直接在你的里面改一下就行了,
代码在下面,只是加了一些阵列,跟你写的差不多,麻烦你看看能否加上框内线,谢谢!
- ;取lwpoline线变宽的地方,并在上生成方框
- ; xiabin68
- ; QQ:19539078
- ; 以下程序没有加入任何子函数希望对初学有帮助
- ;转载请说明出处与作者信息
- (defun c:hk ()
- (setvar "cmdecho" 0)
- (setq os (getvar "osmode"))
- (setq ent (car (entsel"\n请选择多段线:")))
- (setq vlent (vlax-ename->vla-object ent))
- (setq entLEN (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)))
- (setq zb (getpoint "请选择展开起点:"))
- (setvar "osmode" 0)
- (setq zb1 (list (+ 3 (car zb))(+ 1000 (cadr zb))));;;;;;;;;;;;设3偏右离起点距离;1000设距高
- (setq zb3 (list (+ 3 (car zb))(cadr zb)))
- (setq zb2 (list (+ entLEN (car zb1))(+ 1000 (cadr zb))))
- (command "_pline" zb1 zb2 "")
- (setq cenLine (entlast))
- (command ".chprop" cenLine "" "p" "layer" "--008" "");;;;;设线归层
- (command "_array" cenLine "" "r" 5 "1" 1000 );;;;;;;;;;;;;;;;;;;;;设5阵列数量;1000设距高
- (command "_.rectang" zb3 (strcat "@" (rtos entLEN 2) "," (rtos 5000 2)));;;;;;;;;;;;;总高度
- (command ".chprop" (entlast) "" "p" "layer" "--006" "")
- (setq lst (entget ent))
- (setq dd (length lst))
- (setq zblst '())
- (setq i 0)
- (while (/= (car (nth i lst)) 10)
- (setq i (1+ i))
- )
- (setq zblst (append zblst (list (cons 10 zb3)) (list (nth (+ 1 i) lst)) (list (nth (+ 2 i) lst))))
- (while (= 10 (car (nth i lst)))
- (setq x1 (cdr (nth i lst)))
- (if (= (car (nth (+ i 4) lst)) 10)
- (setq x2 (cdr (nth (+ i 4) lst)))
- (setq x2 nil)
- )
-
- (if (and x1 x2)
- (progn
- (setq dist (- (vlax-curve-getDistAtPoint vlent x2) (vlax-curve-getDistAtPoint vlent x1)))
- (setq x3 (polar zb (angtof "0") dist))
- (setq zblst (append zblst (list (cons 10 x3)) (list (nth (+ 5 i) lst)) (list (nth (+ 6 i) lst))))
- (setq zb x3)
- (setq i (+ i 4))
- )
- (setq i 2)
- )
- )
- (setq zblst (append (list (assoc 0 lst) '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (assoc 90 lst)) zblst))
- (entmakex zblst)
- (setq aa (entlast))
- (command ".chprop" aa "" "p" "layer" "--000" "")
- (setq lstt (entget aa))
- (setq n 0)
- (repeat (length lstt)
- (setq nn (car (nth n lstt)))
- (if (= nn 10)
- (progn
- (setq xy (cdr (nth n lstt)))
- (setq high (cdr (nth (1+ n) lstt)))
- (if (and xy (> high 0))
- (progn
- (setq xx (cdr (nth (+ n 4) lstt)))
- (setq xy1 (polar xy (angtof "90") 200));;;;;;;;;;;;;设框离线高度
- (setq xy2 (polar xx (angtof "90") 500));;;;;;;;;;;;;;;;设框高度
- ;(setq textxy (polar xy1 (angle xy1 xy2) (/ (distance xy1 xy2) 3)));算出文字的坐标
- (setq lr (rtos (distance xy xx) 2 2))
- (command "rectang" xy1 xy2)
- (setq Nrec (entlast))
- (command ".chprop" Nrec "" "p" "layer" "--004" "")
- (command "_array" Nrec "" "r" 5 "1" 1000 );;;;;;;;;;;;;;;;;;;;;;;;设5阵列数量和1000距离
- ;(entmakex (list '(0 . "TEXT") ;用文字写出长度
- ; (cons 1 lr)
- ;(cons 10 textxy)
- ; (CONS 40 1.5)
- ;)
- ; )
- )
- )
- )
- )
- (setq n (1+ n))
- )
- (setvar "cmdecho" 1)
- (setvar "osmode" os)
- (princ)
- )
|