Originally Posted by
robertdq885441
but with no luck. i know I need a "while" loop somewere but I can't figure it out. (you do learn something new everyday
)
pbejse thanks to you i had to look into what mapcar and lambda mean and do.
You are welcome, but i'm still not sure of your intent
This?
Code:
(defun c:pl-mid ( / _mid p1-1 p1-2 mp)
(defun _mid (1p 2p)
(mapcar (function (lambda (a b) (* (+ a b) 0.5))) 1p 2p)
)
(if (and (setq p1-1 (getpoint "\n insert p1-1:"))
(setq p1-2 (getpoint p1-1 "\n insert p1-2:"))
(setq mp (_mid p1-1 p1-2))
)
(while
(and (setq p2-1 (getpoint mp "\n insert p2-1:"))
(setq p2-2 (getpoint p2-1 "\n insert p2-2:"))
)
(command "pline" "_non" mp "_non" (setq mp (_mid p2-1 p2-2)) "")
)
)
(princ)
)
or
Code:
(defun c:pl-mid2 ( / _mid p1-1 p1-2 mp)
(defun _mid (1p 2p)
(mapcar (function (lambda (a b) (* (+ a b) 0.5))) 1p 2p)
)
(if (and (setq p1-1 (getpoint "\n insert p1-1:"))
(setq p1-2 (getpoint p1-1 "\n insert p1-2:"))
(setq mp (_mid p1-1 p1-2))
)
(progn
(command "_Pline" mp)
(while (> (getvar "CMDACTIVE") 0)
(if (and (setq p2-1 (getpoint mp "\n insert p2-1:"))
(setq p2-2 (getpoint p2-1 "\n insert p2-2:"))
)
(command (setq mp (_mid p2-1 p2-2)))
(command "")
)
)
)
)
(princ)
)
Makes me wonder why not just use _m2p osnap when selecting the two other points and do away with the lisp code?
Curios is all