DuanJinHui Posted July 29, 2015 Posted July 29, 2015 Hello friends. (setq elist (subst (cons 1 xxx (assoc 1 elist) elist)) (entmod elist) I know DXF code 1 is the only ,so can use "subst" function substitute. But some times ,DXF code is not the only eg. DXF 10 If I need substitute the second DXF 10 , have a quick way ? a function to do this quickly ? I need your advice and example. Thanks _$ (setq ss (ssget ":L" '((0 . "LWPOLYLINE")))) <Selection set: 14> _$ (setq dxf (entget (ssname ss 0))) ((-1 . <Entity name: 7ee38410>) (0 . "LWPOLYLINE") (330 . <Entity name: 7ee36cf8>) (5 . "1F2") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbPolyline") (90 . 6) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 1595.13 1006.01) ;;[color="red"]1[/color] (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1860.27 1131.24) ;;[color="red"]2[/color] (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1964.18 930.87) ;;[color="red"]3[/color] (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2343.98 1038.21);; [color="red"]4[/color] (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2562.54 877.199);; [color="red"]5[/color] (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 2720.19 1002.43) ;; [color="red"]6[/color] (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0)) Quote
rlx Posted July 29, 2015 Posted July 29, 2015 maybe this can help? http://www.afralisp.net/visual-lisp/tutorials/polylines-part-1.php gr.Rlx Quote
marko_ribar Posted July 29, 2015 Posted July 29, 2015 (setq elist (subst (cons 10 xxx) (nth 1 (acet-list-m-assoc 10 elist)) elist)) (entmod elist) Quote
David Bethel Posted July 29, 2015 Posted July 29, 2015 Maybe : for the 3rd vertex : [b][color=BLACK]([/color][/b]setq en [b][color=FUCHSIA]([/color][/b]entlast[b][color=FUCHSIA])[/color][/b] np '[b][color=FUCHSIA]([/color][/b]7.5 6.5[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]nw_elwp en 3 np[b][color=BLACK])[/color][/b] [b][color=BLACK]([/color][/b]defun nw_elwp [b][color=FUCHSIA]([/color][/b]e v np / ed i[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq ed [b][color=NAVY]([/color][/b]entget e[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq i 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]foreach g ed [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]and [b][color=BLUE]([/color][/b]= 10 [b][color=RED]([/color][/b]car g[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]= i v[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]entmod [b][color=BLUE]([/color][/b]subst [b][color=RED]([/color][/b]cons 10 np[b][color=RED])[/color][/b] g ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq i [b][color=BLUE]([/color][/b]1+ i[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= 10 [b][color=BLUE]([/color][/b]car g[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq i [b][color=BLUE]([/color][/b]1+ i[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] np[b][color=BLACK])[/color][/b] -David Quote
Lee Mac Posted July 29, 2015 Posted July 29, 2015 Another function: (defun substnthkey ( n k v l ) (if (assoc k l) (if (= k (caar l)) (if (zerop n) (cons (cons k v) (cdr l)) (cons (car l) (substnthkey (1- n) k v (cdr l))) ) (cons (car l) (substnthkey n k v (cdr l))) ) l ) ) Example: _$ (substnthkey 2 10 "new" '((10 . "a") (11 . "b") (10 . "c") (11 . "d") (10 . "e") (11 . "f"))) ((10 . "a") (11 . "b") (10 . "c") (11 . "d") (10 . "new") (11 . "f")) Quote
DuanJinHui Posted July 29, 2015 Author Posted July 29, 2015 (setq elist (subst (cons 10 xxx) (nth 1 (acet-list-m-assoc 10 elist)) elist)) (entmod elist) marko , cool , this function "acet-list-m-assoc " is from Express Tool ? Maybe :for the 3rd vertex : -David David ,Thanks a lot .Nice function ! very useful . Another function:Example: Lee , Nice function too. Thank you maybe this can help?http://www.afralisp.net/visual-lisp/tutorials/polylines-part-1.php gr.Rlx Hi Rlx . I will try my best to learn . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.