Jump to content

Perpendicular Lines from many points to a Polyline


rifad_cad

Recommended Posts

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

 

Link to comment
Share on other sites

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)))
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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