oliver Posted October 16 Posted October 16 Need a little favor..tired of manual connect..see the attached photo. Thanks once again and Good day. Quote
Tsuky Posted October 17 Posted October 17 Try this (defun c:foo ( / ss e_base pt_base n lst) (princ "\nSelect base point:") (while (null (setq ss (ssget "_+.:E:S" '((0 . "POINT")))))) (setq e_base (ssname ss 0) pt_base (cdr (assoc 10 (entget e_base))) ) (princ "\nSelect points to connect:") (setq ss (ssget '((0 . "POINT")))) (cond (ss (if (ssmemb e_base ss) (ssdel e_base ss)) (repeat (setq n (sslength ss)) (setq lst (cons (cdr (assoc 10 (entget (ssname ss (setq n (1- n)))))) lst)) ) (mapcar '(lambda (x) (entmake (list (cons 0 "LINE") (cons 10 pt_base) (cons 11 x) ) ) ) lst ) ) ) (prin1) ) 3 Quote
mhupp Posted October 17 Posted October 17 Never fully learned mapcar and at this point probably wont. (defun c:foo ( / ss base pt) (setq base (getpoint "\nSelect Base Point:")) (princ "\nSelect Point(s) to Connect:") (setq ss (ssget '((0 . "POINT")))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq pt (cdr (assoc 10 ent))) (entmake (list '(0 . "LINE") (cons 10 base) (cons 11 x))) ) (princ) ) Quote
Tsuky Posted October 17 Posted October 17 Quote Never fully learned mapcar and at this point probably wont. @mhupp (mapcar allows you to apply a function to each member of one or more lists and return the resulting list. simple exemple: (mapcar '1+ '(0 1 2 3 4)) -> (1 2 3 4 5) complex (but powerful) example: (mapcar '(lambda (x y z) (strcat x " "y " " z)) '("me" "you") '("and" "not") '("you" "they")) -> ("me and you" "you not they") Quote
oliver Posted October 17 Author Posted October 17 15 hours ago, Tsuky said: Try this (defun c:foo ( / ss e_base pt_base n lst) (princ "\nSelect base point:") (while (null (setq ss (ssget "_+.:E:S" '((0 . "POINT")))))) (setq e_base (ssname ss 0) pt_base (cdr (assoc 10 (entget e_base))) ) (princ "\nSelect points to connect:") (setq ss (ssget '((0 . "POINT")))) (cond (ss (if (ssmemb e_base ss) (ssdel e_base ss)) (repeat (setq n (sslength ss)) (setq lst (cons (cdr (assoc 10 (entget (ssname ss (setq n (1- n)))))) lst)) ) (mapcar '(lambda (x) (entmake (list (cons 0 "LINE") (cons 10 pt_base) (cons 11 x) ) ) ) lst ) ) ) (prin1) ) thank you very much...its..working. 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.