Chris,
Do you have pseudo code?
Do you have some code worked out?
Show us what you have so far.
In the learning stages you should, in my opinion, use this method.
Create pseudo code and add ;; for each line.
Then add the code segments to accomplish that task.
As you develop the routine the code will evolve & may change location.
That's ok, it's part of the process. Most of my first lisp were cut & paste of code I borrowed from other routines.
That's ok too, it's a way to use a working piece of code to get you started.
Turn your general request into pseudo code
I am trying to create a routine that will allow the user to select a
polyline, and its start point, then have the lisp routine automate creating text
that specifies the distance from the beginning of the polyline and the offset
from the polyline of a point that contains an attribute. This part of the
routine is the step prior to my other post on replacing text in a drawing, it is
the step that will create the text.
Select a polyline
Pick end point of ployline
Get distance from select point to pick point
Then be more specific about your goal
Select ONLY polyline
Pick end point of THE SELECTED ployline
Get distance ALONG THE POLYLINE from select point to pick point
These are important details that will clarify the goal of the routine.
I assume they are implied but we all have a different perspective of the problem.
Code:
(defun c:MyRoutine ()
;; Select ONLY polyline
;; Note, need to trap ENTER
(prompt "\nSelect a polyline.")
(setq ss (ssget "+.:E:S" '((0 . "LWPOLYLINE,POLYLINE"))))
(setq ename (ssname ss 0)))
;; Pick end point of THE SELECTED ployline
;; Note, need to trap ENTER and missed endpoint of matching pline
(setq pt (getpoint "\nPick the endpoint of the polyline."))
;; Get distance ALONG THE POLYLINE from select point to pick point
;; Note, use vlax-curve-getDistAtPoint but to use it we need to determine
;; if the picked point is the END or START of the pline
(princ)
)
Your turn.