spp_wall 发表于 2015-9-16 22:03
作用是?作假么
应该是为了图面更好看 ;;框选范围内交点插入图块By Gu_xl 2011.04
;;;计算曲线交点
(defun Curveinters (en1 en2 / pl pts)
(setq pl(vlax-invoke (vlax-ename->vla-object en2) 'IntersectWith (vlax-ename->vla-object en1) acExtendNone))
(while pl
(setq pts (append pts (list (list (car pl) (cadr pl) (caddr pl))))
pl (cdr (cdr (cdr pl)))
)
)
pts
)
;;;曲线选择集交点
(defun ssinters (ss / pts en1 en2)
(while (> (sslength ss) 1)
(setq en1 (ssname ss 0))
(ssdel en1 ss)
(setq n (sslength ss))
(repeat n
(setq en2 (ssname ss (setq n (1- n))))
(setq pts (append pts (Curveinters en1 en2)))
)
)
pts
)
;;;实例: 按选择范围框内插入图块
(defun c:tt(/ p1 p2 d minX minY maxX maxY pt pts p1 p2 ss os cmdecho blockname )
(setq os (getvar "osmode"))
(setq cmdecho (getvar "cmdecho"))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(setq blockname (getstring"\n插入块名称:"))
(if (null d) (setq d 1.))
(while (and
(setq p1 (getpoint "\n选择插入范围左下角:"))
(setq p2 (GETCORNER p1 "\n选择插入范围左下角:"))
)
(setq minX (apply 'min (mapcar 'car (list p1 p2)))
minY (apply 'min (mapcar 'cadr (list p1 p2)))
maxX (apply 'max (mapcar 'car (list p1 p2)))
maxY (apply 'max (mapcar 'cadr (list p1 p2)))
)
(grvecs (list 1 (list minx miny) (list maxx miny)
1 (list maxx miny) (list maxx maxy)
1 (list maxx maxy) (list minx maxy)
1 (list minx maxy) (list minx miny)
)
)
(setq ss (ssget "c" p1 p2 '((0 . "*line"))))
(if ss
(progn
(setq pts (ssinters ss))
(if pts
(foreach pt pts
(if (and (>= maxX (car pt) minX)
(>= maxY (cadr pt) minY)
)
;;插入图块
(command "insert" blockname "_non" pt 1 1 0)
)
)
)
)
)
(princ "\n ***回车键结束***")
)
(setvar "osmode" os)
(setvar "cmdecho" cmdecho)
(princ)
)
spp_wall 发表于 2015-9-16 22:03
作用是?作假么
仅为lisp学习!
页:
1
[2]