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

Snapping a Point to a Line

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
283 Views, 3 Replies

Snapping a Point to a Line

Good afternoon all,

I have, roughly 3000 points that were digitized without the aid of Object
Snaps. Each point represents a leak point on a water main (Polyline). The
points can be as far away as 8 feet from the main span they should be
snapped to.

What I'm trying to do is find a polyline near each point and then move the
point perpendicular to the polyline.

I can find the point, get its insertion and find the polyline but I can't
seem to figure out how to determine a perpendicular point on the polyline to
act as my "move to point".

Has anyone done this before? Could you help me out?

Thanks, in advance
george
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

A simple way could be to process each point in a while loop changing the
size of the snap box thru each loop until (osnap Point "perp") returns a non
nil value. However this could run pretty slow though, depending on how
complex the pline is.
Just a thought

Rodney
www.homestead.com/designpro/main.html


"George" wrote in message
news:17D10DEB0AD96B3FA3D5E1FE28A4B7FD@in.WebX.maYIadrTaRb...
> Good afternoon all,
>
> I have, roughly 3000 points that were digitized without the aid of Object
> Snaps. Each point represents a leak point on a water main (Polyline).
The
> points can be as far away as 8 feet from the main span they should be
> snapped to.
>
> What I'm trying to do is find a polyline near each point and then move the
> point perpendicular to the polyline.
>
> I can find the point, get its insertion and find the polyline but I can't
> seem to figure out how to determine a perpendicular point on the polyline
to
> act as my "move to point".
>
> Has anyone done this before? Could you help me out?
>
> Thanks, in advance
> george
>
>
Message 3 of 4
Anonymous
in reply to: Anonymous

George

Try this. It's a no frills routine. I haven't really tested it fully but it
worked with a quick test.

(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)
)

Regards
Jason Kroll


"George" wrote in message
news:17D10DEB0AD96B3FA3D5E1FE28A4B7FD@in.WebX.maYIadrTaRb...
> Good afternoon all,
>
> I have, roughly 3000 points that were digitized without the aid of Object
> Snaps. Each point represents a leak point on a water main (Polyline).
The
> points can be as far away as 8 feet from the main span they should be
> snapped to.
>
> What I'm trying to do is find a polyline near each point and then move the
> point perpendicular to the polyline.
>
> I can find the point, get its insertion and find the polyline but I can't
> seem to figure out how to determine a perpendicular point on the polyline
to
> act as my "move to point".
>
> Has anyone done this before? Could you help me out?
>
> Thanks, in advance
> george
>
>
Message 4 of 4
Anonymous
in reply to: Anonymous

Jason,

Nice work! This does exactly what I need. My plan is to use this as a
function and pass entity names to it from an existing while loop.

I have been exposed to the visual lisp coding but haven't actually worked
with it very much. It appears to be easier when wishing to do more complex
processing like this.

Take care,
george

"Jason Kroll" wrote in message
news:AAE89CA38337930DEF1EAE73212239B3@in.WebX.maYIadrTaRb...
> George
>
> Try this. It's a no frills routine. I haven't really tested it fully but
it
> worked with a quick test.
>
> (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)
> )
>
> Regards
> Jason Kroll
>
>
> "George" wrote in message
> news:17D10DEB0AD96B3FA3D5E1FE28A4B7FD@in.WebX.maYIadrTaRb...
> > Good afternoon all,
> >
> > I have, roughly 3000 points that were digitized without the aid of
Object
> > Snaps. Each point represents a leak point on a water main (Polyline).
> The
> > points can be as far away as 8 feet from the main span they should be
> > snapped to.
> >
> > What I'm trying to do is find a polyline near each point and then move
the
> > point perpendicular to the polyline.
> >
> > I can find the point, get its insertion and find the polyline but I
can't
> > seem to figure out how to determine a perpendicular point on the
polyline
> to
> > act as my "move to point".
> >
> > Has anyone done this before? Could you help me out?
> >
> > Thanks, in advance
> > george
> >
> >
>
>

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

Post to forums  

Autodesk Design & Make Report

”Boost