明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1280|回复: 1

谁能帮我找出这里面的错误!谢谢!

[复制链接]
发表于 2012-7-1 20:14:33 | 显示全部楼层 |阅读模式
(defun c:jzxjc()
  (setq val_jz_s 0.0000001)
  (princ "\n检查界址线之间是否重合
   \n程序设置:界址线 layer= jzd\n")
  (setq ss1 (ssget '((0 . "lwpolyline") (8 . "jzd"))))
  (setq n1 0)
  (while (setq name1 (ssname ss1 n1))
    (setq get1 (entget name1))
    (setq val_70 (cdr (assoc 70 get1)))
    (setq pl_coo_list (coord_lwpl get1))
    (setq pl_coo_list (coord_lwpl_c pl_coo_list val_70))
    (setq i 0)
    (setq sum_coo (length pl_coo_list))
    (while (< i (1- sum_coo))
      (setq p1 (nth i pl_coo_list))
      (setq p2 (nth (1+ i) pl_coo_list))
      ;;;判断L_p1-p2是否在同一条界址边上
      (setq val_jzd nil)
      (setq val_009 nil)
      (if (setq ss_jzd (ssget "c" p1 p2 '((0 . "lwpolyline") (8 . "j099"))))
(progn
   (setq n_jzd 0)
   (while (setq name_jzd (ssname ss_jzd n_jzd))
     (setq get_jzd (entget name_jzd))
     (setq val_70_jzd (cdr (assoc 70 get_jzd)))
     (setq jzd_list (coord_lwpl get_jzd))
     (setq jzd_list (coord_lwpl_c jzd_list val_70_jzd))
     (setq i_jzd 0)
     (setq sum_jzd (length jzd_list))
     (while (< i_jzd (1- sum_jzd))
       (setq jzd1 (nth i_jzd jzd_list))
       (setq jzd2 (nth (1+ i_jzd) jzd_list))
       (setq dist_jz (distance jzd1 jzd2))
       (setq dist_p1 (+ (distance jzd1 p1) (distance jzd2 p1)))
       (setq dist_p2 (+ (distance jzd1 p2) (distance jzd2 p2)))
       (setq d_s1 (abs (- dist_jz dist_p1)))
       (setq d_s2 (abs (- dist_jz dist_p2)))
       (if (and (< d_s1 val_jz_s) (< d_s2 val_jz_s))
  (setq val_009 T val_jzd T i_jzd sum_jzd n_jzd (sslength ss_jzd))
       )
       (setq i_jzd (1+ i_jzd))
      
     ) ;;;while i_jzd
     (setq n_jzd (1+ n_jzd))
   ) ;;; while name_jzd
)
      );;; endif
      ;;;如果L_p1-p2不在同一条界址边上,判断是否有009的某一段线与L_p1-p2重合
      (if (not val_jzd)
(progn
   (setq ss_009 (ssget "c" p1 p2 '((0 . "lwpolyline") (8 . "jzd*"))))
   (ssdel name1 ss_009)
   (if ss_009
     (progn
       (setq n_009 0)
       (while (setq name_009 (ssname ss_009 n_009))
  (setq get_009 (entget name_009))
  (setq val_70_009 (cdr (assoc 70 get_009)))
  (setq c009_list (coord_lwpl get_009))
  (setq c009_list (coord_lwpl_c c009_list val_70_009))
  (setq i_009 0)
  (setq sum_009 (length c009_list))
  (while (< i_009 (1- sum_009))
    (setq p009_1 (nth i_009 c009_list))
    (setq p009_2 (nth (1+ i_009) c009_list))
    (setq dist1_1 (distance p1 p009_1))
    (setq dist1_2 (distance p1 p009_2))
    (setq dist2_1 (distance p2 p009_1))
    (setq dist2_2 (distance p2 p009_2))
    (setq dist_min1 (min dist1_1 dist1_2))
    (setq dist_min2 (min dist2_1 dist2_2))
    (if (and (< dist_min1 val_jz_s) (< dist_min2 val_jz_s) )
      (setq i_009 sum_009 n_009 (sslength ss_009) val_009 T)
    )
    (setq i_009 (1+ i_009))
  );;; while i_009
  (setq n_009 (1+ n_009))
       ) ;;;while name_009
     )
   ) ;;;end if ss_009
)
      ) ;;;end if val_jzd
      (if (not val_009) ;;;如果L_p1-p2无重合,在err_reg画线
(progn
   (setq pp2 (list (/ (+ (nth 0 p1) (nth 0 p2)) 2.0) (/ (+ (nth 1 p1) (nth 1 p2)) 2.0)))
   (setq ang_p1p2 (angle p1 p2))
   (setq pp3 (polar pp2 (+ ang_p1p2 (/ PI 2)) 2))
   (command "layer" "m" "err_reg" "c" "3" "err_reg" "")
   (command "osnap" "off")
   (command "pline" pp2 "w" 0 2 pp3 "")
)
      ) ;;;end if (nto val_009)
      (setq i (1+ i))
    ) ;;; while i
    (setq n1 (1+ n1))
    (setq str_pljc (strcat "\n正在检查...... " (rtos (/ n1 (sslength ss1) 0.01) 2 2) "%"))
    (princ str_pljc)
   
  )  ;;;while name1
  (princ "\nok 检查err_reg层中画线处\n")
  (princ)
)

 楼主| 发表于 2012-7-1 20:15:45 | 显示全部楼层
我运行,选择后就出现   错误: 参数类型错误: lselsetp nil
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-16 02:45 , Processed in 0.181255 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表