;; LWPOLY.LSP Copyright 1997 Tony Tanzillo all rights reserved. ;; ;; Excerpt from LWPOLY.LSP from Maximizing AutoLISP R14 ;; ;; (MapLWVertex ) ;; ;; Calls once for each vertex in ;; an LWPOLYLINE, and passes it the vertex ;; data in the form: ;; ;; ( (10 ) ;; (40 . ) ;; (41 . ) ;; (42 . ) ;; ) ;; ;; Each vertex can be modified by , by ;; returning a modified copy of the argument list. ;; If no change to a vertex is desired, ;; MUST return NIL. (defun maplwvertex (pline function / rslt) ( (lambda (vertices) (while (and vertices (eq (caar vertices) 10)) ( (lambda (vertex) (setq rslt (cons (cond ( (apply function (list vertex))) (t vertex) ) rslt ) ) (setq vertices (cddddr vertices)) ) (list (car vertices) (cadr vertices) (caddr vertices) (cadddr vertices) ) ) ) ) (member (assoc 10 pline) pline) ) (append (lwpolyheader pline) (apply 'append (reverse rslt)) (list (assoc 210 pline)) ) ) (defun lwpolyheader (pline) (if (/= (caar pline) 10) (cons (car pline) (lwpolyheader (cdr pline)))) ) ;; ================================================= ;; The TAPER command demonstrates how one might ;; use the MapLWVertex function. ;; ;; This command 'tapers' the width of an existing ;; lightweight polyline by linearly incrementing ;; or decrementing the width of each vertex by a ;; specified value. (defun C:TAPER ( / cwid wstart winc edata e) (setq e (car (entsel "\nSelect LWPolyline: "))) (initget 5) (setq wstart (getdist "\nStarting width: ")) (initget 3) (setq winc (getdist "\nVertex width offset: ")) (setq cwid wstart) (setq edata (maplwvertex (entget e) '(lambda (vertex) (list (car vertex) (cons 40 cwid) (cons 41 (setq cwid (+ cwid winc))) (cadddr vertex) ) ) ) ) (setvar "CMDECHO" 0) (command "._UNDO" "_begin") ;; As incredible as it may seem, to ;; alter vertex width fields, you must ;; REMOVE the default width field :-( (entmod (delete (assoc 43 edata) edata)) (command "._UNDO" "_End") (princ) ) ;; (Delete ) ;; ;; Delete every instance of from (defun delete (expr lst) (apply 'append (subst nil (list expr) (mapcar 'list lst)) ) ) ;; END LWPOLY.LSP