LISP FOR ADD POINT ON POLYLINE

LISP FOR ADD POINT ON POLYLINE

mik501_
Advocate Advocate
1,993 Views
6 Replies
Message 1 of 7

LISP FOR ADD POINT ON POLYLINE

mik501_
Advocate
Advocate

Hello everyone, I'm looking for a lisp for adding points based on the distance we want

. 1. We choose a line. 2. Enter distance 3. Add points

0 Likes
Accepted solutions (3)
1,994 Views
6 Replies
Replies (6)
Message 2 of 7

komondormrex
Mentor
Mentor
Accepted solution

hey,

like that?

(defun c:add_point_both_distance (/ pline _distance_saved)
  (if (null _distance) (setq _distance 6.0))
  (setq pline (car (entsel "\nPick pline to add point at distance both ends: "))
  	_distance_saved _distance
	_distance (getreal (strcat "\nEnter offset distance <" (rtos _distance_saved 2 2) ">: "))
  )
  (if (null _distance) (setq _distance _distance_saved))
  (mapcar '(lambda (point) (vla-addpoint (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
				    		        (vlax-3d-point point)
			   )
	   )
	   (list (vlax-curve-getpointatdist pline _distance) (vlax-curve-getpointatdist pline (- (getpropertyvalue pline "length") _distance)))
  )
  (princ)
)
0 Likes
Message 3 of 7

mik501_
Advocate
Advocate

It works great. I was wondering if you could adapt it to work with multiple polyline. Thank you so much

0 Likes
Message 4 of 7

komondormrex
Mentor
Mentor
Accepted solution

sure

(defun c:add_point_both_distance (/ pline _distance_saved)
  (if (null _distance) (setq _distance 6.0))
  (prompt "\nPick pline to add point at distance both ends")
  (setq pline_sset (ssget '((0 . "lwpolyline"))))
  (if pline_sset
    (progn
	  (setq _distance_saved _distance
		_distance (getreal (strcat "\nEnter offset distance <" (rtos _distance_saved 2 2) ">: "))
	  )
	  (if (null _distance) (setq _distance _distance_saved))
      	  (foreach pline (vl-remove-if 'listp (mapcar 'cadr (ssnamex pline_sset))) 
		  (mapcar '(lambda (point) (vla-addpoint (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
						    		        (vlax-3d-point point)
					   )
			   )
			   (list (vlax-curve-getpointatdist pline _distance) (vlax-curve-getpointatdist pline (- (getpropertyvalue pline "length") _distance)))
		  )
    	  )
    )
  )
  (princ)
)
Message 5 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

Another approach is the DIV+ command in DivideMeasurePlus.lsp, >here<.  One of its enhancements over the regular DIVIDE command is that it has the option to inset the end placements by whatever distance you like [your 6 units].  Ask it to divide the path into one segment [which regular DIVIDE won't allow] and inset the ends.  See other comments at the top.

 

It also gives you options about what to put there -- Points, Blocks, perpendicular Line markers of your specified length, even copies of any User-selected object(s).  And it works on any finite path-type object(s) [Line, Arc, Circle, Polyline of any variety, Spline, Ellipse].

 

It doesn't let you select a lot of path objects collectively at the beginning, but in one running of the command you can go around and pick as many paths as you want to be marked in the same way.  One reason for doing it that way is that if you pick a path that's too short for your inset distance, it notifies you, but carries on without error to let you pick another path.

Kent Cooper, AIA
Message 6 of 7

manasi4532
Enthusiast
Enthusiast
WOW Thank you so much.
0 Likes
Message 7 of 7

manasi4532
Enthusiast
Enthusiast
Very thank you .
0 Likes