@GeryKnee a écrit :
Hello ronjonp.
just only those create after the target polyline creation.
Regards,
Gery
It's doable...
I take this opportunity to also improve 2 other points that have appeared in use.
1 - If Xdata are present, then reproduce them on the cut segments, currently they are lost.
2 - If used with (for me) Map or Civil (or other products which can use dictionaries) the procedure generates errors on the cut segments if dictionaries are used.
We can correct with _AUDIT, but it's not very clean ...
Note: For autocad Map, you can do the same as for XData, copy the Object Data, version not proposed here.
Here is the version of ronjonp still modified:
(vl-load-com)
(defun c:lw_split ( / a b c e el hndl xd_l l1 l2 n r s x)
;; RJP » 2021-01-20
;; Splits a polyline with other polylines that share a common vertex
;; modified by B.Valsecchi for keep Xdata and resolve dictionnary conflicts
(cond ((and (setq e (car (entsel "\nPick polyline to split: ")))
(= "LWPOLYLINE" (cdr (assoc 0 (setq el (entget e (list "*"))))))
(setq hndl (cdr (assoc 5 el)))
(not (vla-getboundingbox (vlax-ename->vla-object e) 'a 'b))
(mapcar 'set '(a b) (mapcar 'vlax-safearray->list (list a b)))
(setq s (ssdel e (ssget "_C" a b '((0 . "LWPOLYLINE,LINE")))))
;; Save 's' to list to delete later
(> (length (setq s (mapcar 'handent (vl-remove-if '(lambda (x) (< x hndl)) (mapcar '(lambda (x) (cdr (assoc 5 (entget x)))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))))))) 0)
)
(setq xd_l (assoc -3 el))
(foreach n el (if (member (car n) '(-1 5 102 330 360)) (setq el (vl-remove (assoc (car n) el) el))))
(foreach p s (setq c (cons (vl-remove-if-not '(lambda (x) (member (car x) '(10 11))) (entget p)) c)))
(setq c (mapcar '(lambda (x) (cons 10 (list (car x) (cadr x)))) (mapcar 'cdr (apply 'append c))))
(setq l1 (reverse (cdr (member (assoc 10 el) (reverse el)))))
(setq l1 (subst '(70 . 0) (assoc 70 l1) l1))
(setq l2 (reverse (cdr (reverse (member (assoc 10 el) el)))))
(and (= 1 (logand 1 (cdr (assoc 70 el)))) (setq l2 (append l2 (list (assoc 10 el)))))
(foreach p l2
(if (vl-some '(lambda (x) (equal p x 1e-8)) c)
(progn (setq r (cons p r))
(entmake (append l1 (reverse r) (if xd_l (list xd_l) '())))
(setq r (list p))
;; Remove point from 'c' so it does not get looked at twice
(setq c (vl-remove p c))
)
(setq r (cons p r))
)
)
(entmake (append l1 (reverse r) (if xd_l (list xd_l) '())))
;; Delete all ( beware it will delete all items found within bounding
;; box so further code is needed to delete only 'cutters' )
(mapcar 'entdel (cons e s))
)
)
(princ)
)