- 积分
- 1168
- 明经币
- 个
- 注册时间
- 2013-7-27
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2013-8-21 21:10:08
|
显示全部楼层
本帖最后由 yeahyeah 于 2013-8-21 21:12 编辑
;;画多段线打断于交点处
(defun c:kk (/ LA P0 PT S PL A d)
(if (null *d*)
(setq *d* 0)
)
(setq d (getdist (strcat "\n打断距离<" (rtos *d* 2 2) ">:")))
(if (null d)
(setq d *d*)
(setq *d* d)
)
(setq d (* 0.5 d))
(setq xww (getvar 'Plinewid)) ;线宽
(setq la (getvar 'clayer))
(setq p0 (getpoint "\n第一点:"))
(while (setq pt (getpoint p0 "\n下一点:"))
(setq s
(ssget "f"
(list p0 pt)
(list (cons 0 "*line,LWPOLYLINE,arc,circle,ellipse")
(cons 8 la);只能在一个图层里
)
)
)
(if s
(progn
(setq pl ;我感觉问题就出在这个setq语句里
(vl-sort
(apply 'append ;apply function
(mapcar
'(lambda (x) (mapcar 'cadr (cdddr x)))
;mapcar function
(ssnamex s) ;mapcar list1
) ;apply list
) ;end apply ;vl-sort list
'(lambda (a b)
(< (distance a p0) (distance b p0))
) ;lambda:参数是两个点 ;vl-sort comparison-function
) ;end vl-sort
)
(setq a p0)
(foreach b pl
(if (not (equal p0 b (* 0.1 d)))
(progn
(entmake
(list
'(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(90 . 2)
(cons 43 xww)
(cons 10 a)
(cons 10 (polar b (angle pt p0) d))
)
)
(setq a (polar b (angle p0 pt) d))
)
) ;整个if是foreach的求值表达式
)
(entmake
(list
'(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(90 . 2)
(cons 43 xww)
(cons 10 a)
(cons 10 pt)
)
)
)
(entmake
(list
'(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(90 . 2)
(cons 43 xww)
(cons 10 p0)
(cons 10 pt)
)
)
)
(setq p0 pt)
)
(princ)
) |
|