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

snapping to the endpoint of a line

7 REPLIES 7
Reply
Message 1 of 8
autobot00
170 Views, 7 Replies

snapping to the endpoint of a line

Hey folks, heres my question. How do i snap to the end point of a line using entget?

for example i want to use:
(setq line (entget "\nSelect line:"))

but i want to get the endpoint closest to where i picked the line. this is not an assoc 11 question, i want it to find the endpoint as if i were using osnaps. Just incase there is any confusion i made a jpg showing what i want. Any ideas? thanks in advance.
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: autobot00

Use (entsel.... and the find out where the point that is retuned by it is
closest to. You may also want to check to make sure you only select a line.
Something like

(if
(and
(setq Sel (entsel "\n Select line: "))
(setq EntData (entget (car Sel)))
(= (cdr (assoc 0 EntData)) "LINE")
(setq Pt (cadr Sel))
(setq StPt (cdr (assoc 10 EntData)))
(setq EndPt (cdr (assoc 11 EntData)))
)
(if (< (distance Pt StPt) (distacne Pt EndPt))
StPt
EndPt
)
)

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5249088@discussion.autodesk.com...
Hey folks, heres my question. How do i snap to the end point of a line
using entget?

for example i want to use:
(setq line (entget "\nSelect line:"))

but i want to get the endpoint closest to where i picked the line. this is
not an assoc 11 question, i want it to find the endpoint as if i were using
osnaps. Just incase there is any confusion i made a jpg showing what i
want. Any ideas? thanks in advance.
Message 3 of 8
EC-CAD
in reply to: autobot00

(defun get_closest_endpoint ()
(setq line (entsel "\nSelect line:"))
(if line
(progn
(setq ent (car line))
(setq PT (cadr line))
(setq elist (entget ent))
(setq PA (cdr (assoc 10 elist)))
(setq PB (cdr (assoc 11 elist)))
(if (> (distance PT PA)(distance PT PB))
(setq PT PB)
(setq PT PA)
); if
); progn
); if
PT
); function
;;
;; Usage
;; (setq Pnt (get_closest_endpoint))

Bob
Message 4 of 8
autobot00
in reply to: autobot00

sweet this works thank you.
Message 5 of 8
autobot00
in reply to: autobot00

nice this one works too, thank you.
Message 6 of 8
Anonymous
in reply to: autobot00

How about this?

(defun c:sln()
(setq ent (entsel))
(setq pt1 (osnap (cadr ent) "end"))
)
Message 7 of 8
autobot00
in reply to: autobot00

well this is much less code and it works. i think i'll go with this one. thanks.
Message 8 of 8
devitg
in reply to: autobot00

Just a lean rutine.
Thanks

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

Post to forums  

Autodesk Design & Make Report

”Boost