distance and offset along a polyline
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.
If at all possible I would like to have the "X" coordinate of the text insert to be = to the distance from the start point, with a specific "y" coordinate and if the text will overlap, specify a minimum distance apart for the next text object.
The main points that I need help with is getting the information, and then actually creating the text object. I am not sure how to create something from nothing, the only thing up to this point that I have ever been able to do is edit something that already exists.
any help is greatly appreciated.
RE: distance and offset along a polyline
sounds like you are trying to do something like LDT does with alignments and station labels?
RE: distance and offset along a polyline
that is exactly what I am trying to do, except I am using vanilla AutoCAD, we dont have LDT and as far as I know my office has no plans to leave Eagle Point. we have a program that does this already, but it doesn't work the way I would like it to. and it is written very poorly so I dont want to use any of it, I figured it would be easier to start from scratch.
RE: distance and offset along a polyline
sounds like you could do a modified measure command that will use the spacing you define to measure at, the distance and incrementally add that to every block suscinctly
RE: distance and offset along a polyline
no, that wouldn't work, the points are already in the drawing and not specific distances from the start of the polyline, measure would be more for a set distance apart, as for the placement of the text, I will know the y coordinate, for x I would just use a logic test to determine if they are too close together
Code:
(if (< (- x1 x2) (* 0.5 Textheight))
(setq x2 (+ (* 0.5 Textheight) x1))
)
RE: distance and offset along a polyline
sounds like after all the few posts i've read from ya that you need civil 3d or ldt because it does all of this stuff you are doing through customization.
eagle point is ok for landscaping but thats about the only use i found for it.
RE: distance and offset along a polyline
well, my company has no plans to switch, I would prefer that they would, so I have to deal with what I have. The program can be written, I just need to know how to collect the data I need, and create a text object.
RE: distance and offset along a polyline
I think the one for single text will work, I just need to adjust it for what I want, It is a good starting off point, hopefully someone will help out with the collection of the data part today, so I can try to get a working program by Tuesday, or at least more questions
RE: distance and offset along a polyline
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
Quote:
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. :)