仅限于LINE- (vl-load-com)
- (defun c:breakall( / ss n i j ents ent1 ent2 pts)
- (setq ss (ssget '((0 . "line"))))
- (setq n (sslength ss))
- (setq i 0)
- (while (< i n)
- (setq ents (append ents (list (list (ssname ss i)))))
- (setq i (1+ i))
- )
- (setq i 0)
- (while (< i n)
- (setq j (1+ i))
- (setq ent1 (ssname ss i))
- (while (< j n)
- (setq ent2 (ssname ss j))
- (setq pts (getinterpoint ent1 ent2))
- (if pts
- (progn
- (setq ents (subst (append (assoc ent1 ents) pts) (assoc ent1 ents) ents))
- (setq ents (subst (append (assoc ent2 ents) pts) (assoc ent2 ents) ents))
- )
- )
- (setq j (1+ j))
- )
- (setq i (1+ i))
- )
- (mapcar 'breaks ents)
- (princ ents)
- )
- (defun GetInterPoint (ent1 ent2 / ax_ent_1 ax_ent_2 intpoints points i)
- (setq ax_ent_1 (vlax-ename->vla-object ent1)
- ax_ent_2 (vlax-ename->vla-object ent2)
- )
- (setq intpoints (vla-intersectwith ax_ent_1 ax_ent_2 acextendnone))
- (setq intpoints (vlax-variant-value intpoints))
- (setq i 0)
- (if (> (vlax-safearray-get-u-bound intpoints 1) 0)
- (repeat (/ (+ 1
- (- (vlax-safearray-get-u-bound intpoints 1)
- (vlax-safearray-get-l-bound intpoints 1)
- )
- )
- 3
- )
- (setq points (append points (list (list
- (vlax-safearray-get-element intpoints i)
- (vlax-safearray-get-element intpoints (+ i 1))
- (vlax-safearray-get-element intpoints (+ i 2))
- )))
- )
- (setq i (+ 3 i))
- )
- )
- points
- )
- (defun breaks(lst / n i sname sinf ptstart ptend pts)
- (setq sname (car lst))
- (setq sinf (entget sname))
- (setq ptstart (cdr (assoc 10 sinf)))
- (setq ptend (cdr (assoc 11 sinf)))
- (setq pts (cdr lst))
- (setq pts (vl-sort (append (list ptstart ptend) pts) '(lambda(e1 e2) (> (car e1) (car e2)))))
- (setq n (length lst))
- (setq i 0)
- (mapcar 'command (append (list "_.line") pts (list "")))
- (entdel sname)
- )
|