Here are some quickly written functions that may be of help -
; (GetInstancesOf (lambda (x)(= 10 (car x))) (entget (car (entsel "\nPick polyline"))))
; >> ((10 1288.07 1710.1) (10 2258.12 2318.01) (10 2529.53 2318.01) (10 3871.5 1865.85) (10 4595.26 2368.25) (10 5032.54 2212.5))
; tf - test function
; L - list
(defun GetInstancesOf ( tf L )
( (lambda (f tf L) (f tf L))
(lambda (tf L)
(if (setq L (vl-member-if 'tf L))
(cons (car L) (f tf (cdr L)))
)
)
tf L
)
); defun
; (SubstInstances '((x)(= 10 (car x))) '(0 2) '("Donald" "Trump") (entget (car (entsel "\nPick polyline"))))
; >>
; ((-1 . <Entity name: 76940ffd10>) (0 . "LWPOLYLINE") (330 . <Entity name: 76b2f399f0>) (5 . "269") (100 . "AcDbEntity")
; (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbPolyline") (90 . 6) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0)
; "Donald" (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0)
; (10 2258.12 2318.01) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0)
; "Trump" (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0)
; (10 3871.5 1865.85) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0)
; (10 4595.26 2368.25) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0)
; (10 5032.54 2212.5) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0)
; )
; sL - source list
; tf - test function
; nL - positions to subst
; aL - list of new items
(defun SubstInstances ( tf nL aL sL / i )
(setq i -1)
(mapcar
(function
(lambda (x / itm)
(cond
( (not (tf x)) x)
( (not aL) x)
( (member (setq i (1+ i)) nL) (setq itm (car aL)) (setq aL (cdr aL)) itm)
(x)
); cond
); lambda
); function
sL
); mapcar
); defun
And heres some test function (tested on a LWPOLYLINE, since it has multiple dxf 10 values in its elist and its a graphical entity which is suitable for a preview during testing) -
(defun C:test ( / enx vL nL p p2 )
(and
(setq enx (car (entsel "\nPick a polyline: ")))
(setq enx (entget enx))
(member '(0 . "LWPOLYLINE") enx)
(setq vL (GetInstancesOf '((x)(= 10 (car x))) enx))
(setq nL ('((f n) (reverse (f (1- n)))) '((n) (if (> n -1) (cons n (f (1- n))))) (length vL)))
(progn
(foreach n nL ; use 'nL' or a custom list like: '(0 2 5 12)
(and
(setq p2 (nth n vL))
(setq p
(getpoint (cdr p2)
(strcat
"\nSpecify new " (itoa (1+ n))
(cond
( (nth n '("st" "nd" "rd" "th")) )
("th")
)
" vertex of the polyline: "
)
)
)
(setq enx (SubstInstances '((x)(= 10 (car x))) (list n) (list (cons 10 p)) enx)) ; update within the iteration for a real-time preview
(entmod enx)
); and
); foreach
(princ "\nPress anything to restore the shape") (grread)
(entmod (SubstInstances '((x)(= 10 (car x))) nL vL enx))
); progn
)
(princ)
); defun