Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Move point perpendicular to line

1 REPLY 1
Reply
Message 1 of 2
antoniomiranda
2132 Views, 1 Reply

Move point perpendicular to line

Hello,

I've this code to move some AcadPoints tPerpendicular of one 2DPoliline.
The problem: I've this points with Z value, when i run the code this points goes perpendicular to line but with Z=0.

(defun c:SnapToObj ( / en obj pts_ss ss_len c pten ptobj pted pt pt2)
(setq en (car (entsel "\nSelect Object: ")))
(setq obj (vlax-ename->vla-object en))
(princ "\nSelect points: ")
(setq pts_ss (ssget (list (cons 0 "POINT"))))
(setq ss_len (sslength pts_ss))
(setq c 0)
(while (< c ss_len)
(setq pten (ssname pts_ss c))
(setq ptobj (vlax-ename->vla-object pten))
(setq pted (entget pten))
(setq pt (cdr (assoc 10 pted)))
(setq pt2 (vlax-curve-getClosestPointTo obj pt))
(vla-move ptobj (vlax-3d-point pt) (vlax-3d-point pt2))
(setq c (+ c 1))
)
(princ)
)

Best regards,
António Miranda.
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: antoniomiranda

wrote in message news:5771248@discussion.autodesk.com...
Hello,

I've this code to move some AcadPoints tPerpendicular of one 2DPoliline.
The problem: I've this points with Z value, when i run the code this points goes perpendicular to line but with Z=0.

(defun c:SnapToObj ( / en obj pts_ss ss_len c pten ptobj pted pt pt2)
(setq en (car (entsel "\nSelect Object: ")))
(setq obj (vlax-ename->vla-object en))
(princ "\nSelect points: ")
(setq pts_ss (ssget (list (cons 0 "POINT"))))
(setq ss_len (sslength pts_ss))
(setq c 0)
(while (< c ss_len)
(setq pten (ssname pts_ss c))
(setq ptobj (vlax-ename->vla-object pten))
(setq pted (entget pten))
(setq pt (cdr (assoc 10 pted)))
(setq pt2 (vlax-curve-getClosestPointTo obj pt))
(vla-move ptobj (vlax-3d-point pt) (vlax-3d-point pt2))
(setq c (+ c 1))
)
(princ)
)

Best regards,
António Miranda.

I assume you want to preserve the Z coordinate.
You could list the X and Y coordinates of PT2 and the Z coordinate of PT and use that as the destination point:
(entmod(subst(list 10(car pt2)(cadr pt2)(last pt))(assoc 10 pted)pted))

Regards,

Mel

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost