各位前辈,关于判断点是否在多段线内我在论坛找了代码,因为本人没有lisp基础,自己胡乱拼了一下,结果不出所料,运行错误!显示的错误为:"; 错误: 参数类型错误: 二维/三维点: nil"
麻烦各位帮忙看一看怎么弄,谢谢了.附上自己乱拼的代码,欢迎嘲讽,但请不吝指导.- (defun c:z1 (/)
- (prompt "此程序根据当前标注样式进行标注,设置textsize变量可修改与标注线的距离!")
- (setq dic (* 7 (getvar "dimscale")))
- (setq ss (ssget))
- (setq n 0)
- (repeat (sslength ss)
- (setq en (ssname ss n))
- (setq endata (entget en))
- (if (= (cdr (assoc 0 endata)) "LWPOLYLINE")
- (mmh_3 en)
- (if (= (cdr (assoc 0 endata)) "ARC")
- (mmh_1 en)
- (mmh_2 endata)
- )
- )
- (setq n (1+ n))
- )
- (princ)
- )
- (prompt "<<z1>>快速标注")
- (defun mmh_1 (en)
- (setvar "osmode" 0)
- (setq po_1 (vlax-curve-getstartPoint en))
- (setq po_2 (vlax-curve-getendPoint en))
- (setq po_1_x (car po_1))
- (setq po_1_y (cadr po_1))
- (setq po_2_x (car po_2))
- (setq po_2_y (cadr po_2))
- (command "dimaligned" po_1 po_2 po_1)
- (setvar "osmode" 16383)
- )
- (defun mmh_2 (endata)
- (setvar "osmode" 0)
- (setq p_1 (cdr (assoc 10 endata)))
- (setq p_2 (cdr (assoc 11 endata)))
- (setq p3 (polar p_1 (+ (angle p_1 p_2) (/ pi 2)) dic))
- (cond
- ((isptinpm p3 endata)
- (setq px (polar p_2 (+ (angle p_2 p_1) (/ pi 2)) dic))
- )
- (t
- (setq px p3)
- )
- )
- (command "dimaligned" p_1 p_2 px)
- (setvar "osmode" 16383)
- )
- (defun mmh_3 (en)
- (setq m 0)
- (command "explode" en "")
- (setq ssl (ssget "p"))
- (repeat (sslength ssl)
- (setq enl (ssname ssl m))
- (setq enldata (entget enl))
- (if (= (cdr (assoc 0 enldata)) "ARC")
- (mmh_1 enl)
- (mmh_2 enldata)
- )
- (setq m (1+ m))
- )
- (command "pedit" "m" ssl "" "j" "" "")
- )
- ;判断点是否在多边形内
- (defun isptinpm (/pt ptl)
- (equal pi(abs(apply '+(mapcar'(lambda (x y)(rem (- (angle pt x) (angle pt y)) pi))
- (reverse (cdr (reverse (cons (last ptl) ptl))))
- ptl
- )
- )
- )
- 1e-6
- )
- )
|