Jump to content

Recommended Posts

Posted

Need a little favor..tired of manual connect..see the attached photo.

Thanks once again and Good day.

AUTOLISP_REQUEST-01.jpg

Posted

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)
)

 

  • Like 3
Posted

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)
)

 

Posted
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")

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...