asra Posted October 18, 2019 Posted October 18, 2019 thaks @leemac to you response, but i dont understand, cause im newbie so which code do you think should be changed or added? (defun c:test ( / ent ss cnt e_lst i_pt c_pt) (setq ent (car (entsel "\nSelect Line Entity : "))) (cond ( (vl-position (cdr (assoc 0 (entget ent))) '("LWPOLYLINE" "ARC" "LINE" "CIRCLE" "ELLIPSE" "SPLINE")) (prompt "\nSelect Points : ") (setq ss (ssget '((0 . "POINT,TEXT")))) (repeat (setq cnt (sslength ss)) (setq i_pt (cdr (assoc 10 (setq e_lst (entget (ssname ss (setq cnt (1- cnt))))))) c_pt (vlax-curve-getclosestpointto ent i_pt) ) (entmod (subst (cons 10 c_pt) (assoc 10 e_lst) e_lst)) );end_repeat ) ( (alert "Not a Line Entity")) );end_cond (princ) );end_defun Quote
BIGAL Posted October 18, 2019 Posted October 18, 2019 Un tested but change this line c_pt (vlax-curve-getclosestpointto ent i_pt) 1 Quote
dlanorh Posted October 20, 2019 Posted October 20, 2019 c_pt (vlax-curve-getclosestpointto ent i_pt) c_pt (vlax-curve-getclosestpointtoprojection ent i_pt) Quote
marko_ribar Posted October 20, 2019 Posted October 20, 2019 No, dlanorh... It should be : c_pt (vlax-curve-getclosestpointto ent i_pt) c_pt (append (mapcar '+ '(0 0) (vlax-curve-getclosestpointto ent i_pt)) (list (caddr i_pt))) Quote
Lee Mac Posted October 20, 2019 Posted October 20, 2019 On 10/17/2019 at 1:06 PM, Lee Mac said: Hint: use the vlax-curve-getclosestpointtoprojection function instead, for reasons I describe here. This is the method I was suggesting - (defun c:test ( / e i p q s x ) (if (and (setq s (ssget "_:L" '((0 . "POINT")))) (progn (while (progn (setvar 'errno 0) (setq e (entsel)) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null e) nil) ( (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getclosestpointto e)) (princ "\nInvalid object selected.") ) ) ) ) (setq e (car e)) ) ) (repeat (setq i (sslength s)) (setq i (1- i) x (entget (ssname s i)) p (assoc 10 x) q (vlax-curve-getclosestpointtoprojection e (list (cadr p) (caddr p)) '(0 0 1)) ) (entmod (subst (list 10 (car q) (cadr q) (cadddr p)) p x)) ) ) (princ) ) (vl-load-com) (princ) This accounts for points & curve objects residing at different elevations, with the closest point calculated in the WCS plane. 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.