;|
   命令：wkz_draw
   轴网交点布挖孔桩wkz_draw
   说明：1、程序可以判断轴网交点，有重复轴线的只插一个桩
        2、程序要求的挖孔直径和扩大头直径以后画桩表的时候使用
        3、挖孔桩图层WKZ
        4、相关图层定义请查layerdef.dat文件
        
        程序配合XDRX_API build 20428＋版本使用，朋友们可以把这个LISP拷贝到“晓东工具箱”的安装的
          LISP目录，自己加入到菜单里面就可以非常方便的使用了。
          关于程序的建议请到“晓东CAD空间-编程申请”论坛
          http://www.xdcad.com/forum留言         
|;
(defun c:wkz_draw (/ xdrx_getptss old_cmd ss intl p1 wkz_zj wkz_kdzj n e)
(defun xdrx_getptss ( pt distl filters / )
  (setq distl (list distl distl 0))
  (if filters
      (ssget "c" (mapcar '- pt distl) (mapcar '+ pt distl) filters)
      (ssget "c" (mapcar '- pt distl) (mapcar '+ pt distl))
  )
)
  (mai_start nil)
  (princ "\n轴网交点布挖孔桩.")
  (and (setq ss (ssget (list (cons 8 (car maiaxisname)) '(0 . "line,arc"))))
	   (setq intl (mai_inters_all ss))
  )
  (if (= (length intl) 0) (exit))
  (setq #wkz_zj (cond (#wkz_zj) (800))
        #wkz_kdzj (cond (#wkz_kdzj) (#wkz_zj))
        wkz_zj (getint (strcat "\n请输入挖孔桩直径<" (itoa #wkz_zj) ">:"))
        wkz_zj (cond (wkz_zj) (#wkz_zj))
        #wkz_zj wkz_zj
        wkz_kdzj (getint (strcat "\n请输入挖孔桩扩大头直径<" (itoa #wkz_kdzj) ">:"))
        wkz_kdzj (cond (wkz_kdzj) (#wkz_kdzj))
        #wkz_kdzj wkz_kdzj
        wkz_layer (cond (wkz_layer) ((list "wkz" "2")))
        blkna (strcat "WKZ_" (itoa wkz_zj) "X" (itoa wkz_kdzj))
	    intl (mai_remove_same intl)
        mai_wkz_layer (cond (mai_wkz_layer) ((list "WKZ" "2")))
  )
  (if (not (tblsearch "block" blkna))
	  (progn (setq p1 (trans (list 0 0 0) 0 1))
	         (setvar "clayer" "0")
	         (mai_entmake "circle" (list p1 (/ wkz_zj 2)))
	         (setq ss (ssadd))
	         (ssadd (entlast) ss)
			 (mai_addblock blkna p1 ss)
	  )
  )
  (apply 'mai_create_layer mai_wkz_layer)
  (foreach n intl
	(if (setq ss (xdrx_getptss n wkz_zj (list (cons 0 "insert") (cons 2 "WKZ_*") (cons 8 (car mai_wkz_layer)))))
	    (while (setq e (ssname ss 0))
	           (ssdel e ss)
	            (if (mai_equal (trans (mai_dxf 10 e) 0 1) n)
		            (entdel e)
	            )
	    )
	)
	(command ".insert" blkna "non" n "" "" "")
  )
  (mai_end)
)
