liupengchao221 发表于 2012-11-30 20:48:29

悬挂线解决方案


求解释。。是否能没行都解释下。。。对LISP不了解 翻译成VB伪代码 最好

(defun c:lll ()
(setvar "CMDECHO" 1)
(setq ssd (ssget "x" ' ( (0 . "LWPOLYLINE") (-4 . "<OR") (70 . 129) (70 . 1) (-4 . "OR>"))))
(if ssd
(progn
(setq i 0)
(repeat (sslength ssd)
   (setq eed (entget (ssname ssd i) '("*")))
   (setq aa ())
   (foreach n eed (if (= 10 (car n) ) (setq aa (cons (cdr n) aa) ) ) )
   (setq ssd0 ssd)
   ;(ssdel (ssname ssd i) ssd0)
   (if ssd0
   (progn
   (setq m 0)
   (repeat (length aa)
    (setq xy (nth m aa))
    (setq j 0)
    (repeat (sslength ssd0)
   (setq eed0 (entget (ssname ssd j) '("*")))
   (setq a0 ())
   (foreach n eed0 (if (= 10 (car n) ) (setq a0 (cons (cdr n) a0) ) ) )
   (setq a0 (reverse (cons (car (reverse a0)) a0)))
   (setq n 0)
   (repeat (- (length a0) 1)
      (if (and (> (distance xy (nth (1+ n) a0)) 0.002) (> (distance xy (nth n a0)) 0.002) (< (- (+ (distance xy (nth n a0)) (distance xy (nth (1+ n) a0))) (distance (nth (1+ n) a0) (nth n a0))) 0.002)(< (- (angle (nth n a0) xy) (angle xy (nth (1+ n) a0))) 0.001))
       (progn
      (setq c10 (cons 10 (nth (1+ n) a0)))
      (setq eed1 ()eed00 eed0)
      (repeat (length eed0)
         (if (equal (car eed00) c10)
          (progn
         (setq eed1 (cons (cons 10 xy) eed1))
         (setq eed1 (cons (cons 40 0.0) eed1))
         (setq eed1 (cons (cons 41 0.0) eed1))
         (setq eed1 (cons (cons 42 0.0) eed1))
         (setq eed1 (cons (car eed00) eed1))
         (setq eed00 (cdr eed00))
          )
          (progn
         (setq eed1 (cons (car eed00) eed1))
         (setq eed00 (cdr eed00))
          )
         )
      )
      (setq eed1 (reverseeed1))
      (entmod eed1)
       )
      )
      ;(setq eed00 eed1)
      (setq n (1+ n))
   )

   (setq j (1+ j))
    )
    (setq m (1+ m))
   )
   )
   )
   (setq i (1+ i))
)
)
)
(princ)
)

页: [1]
查看完整版本: 悬挂线解决方案