Show Distance between two lines at fixed interval

Show Distance between two lines at fixed interval

Anonymous
Not applicable
8,120 Views
26 Replies
Message 1 of 27

Show Distance between two lines at fixed interval

Anonymous
Not applicable

Hi,

 

I have a project where a cable is laid along a road. I need to show the perpendicular distance of the cable from the road centerline at every 10m interval. I cannot do it manually as the cable length is in 100s of kms. I have been using autocad for a long time but am new to LISP. 

 

Is there a LISP code that can do this?

 

Please help.

 

Thanks

0 Likes
Accepted solutions (1)
8,121 Views
26 Replies
Replies (26)
Message 21 of 27

devitg
Advisor
Advisor

@brodie.mclean Maybe . like it ?

 

 

0 Likes
Message 22 of 27

brodie.mclean
Contributor
Contributor

Yes, something like this is what I'm looking for. 

0 Likes
Message 23 of 27

Anonymous
Not applicable

I hate to revive a dead thread but I was wondering how I could add text to the annotation such as "proposed R/L" or even just R/L. Preferably asking for a prompt that the user can specify the text each time. I know how to enter it manually in text properties but Want to make it more efficient.

Thank you in advance. 

0 Likes
Message 24 of 27

Sea-Haven
Mentor
Mentor

Post sample dwg so explains what you want

0 Likes
Message 25 of 27

Anonymous
Not applicable

BStarkG4HYT_0-1639667136450.png

I have worked on the code since asking my question and I think I'm almost there. this is what I have right now.

 

(vl-load-com)

(defun c:AUTODIM ( / en1 en2 int len stt len pt1 pt2 prefix linty new dim newdimvalue)

(if (and (setq en1 (car (entsel "\nSelect 1st polyline (dim from): ")))
(= "LWPOLYLINE" (cdr (assoc 0 (entget en1))))
(setq en2 (car (entsel "\nSelect 2nd polyline (dim to): ")))
(= "LWPOLYLINE" (cdr (assoc 0 (entget en2))))
(setq int (getdist "\nInterval: "))
(setq len (vlax-curve-getDistAtParam en1 (vlax-curve-getEndParam en1)))
(not (initget 4))
(setq stt (cond ((getreal "\nDistance at the beginning <0>: "))
(0)))
(not (initget 4))
(setq len (cond ((getreal (strcat "\nDistance at the end <Use the entire polyline = " (rtos len 2 2) ">: ")))
(len)))
(setq prefix "<>' ")
(setq linty (cond ((getstring T "\nWhat are you measuring to? <R/W>: "))
("R/W")))
)
(while (and (<= stt len)
(setq pt1 (vlax-curve-getPointAtDist en1 stt))
(setq pt2 (vlax-curve-getClosestPointTo en2 pt1)))
(command-s "_.DIMALIGNED"
"_none" (trans pt1 0 1)
"_none" (trans pt2 0 1)
"_none" (polar (trans pt1 0 1)
(+ (* 1.5 pi)
(angle (trans pt1 0 1) (trans pt2 0 1)))
1.5))
(setq newdim (entlast))
(setq newdimvalue (strcat prefix linty))
(command "dimedit" "n" newdimvalue newdim "")
(setq stt (if (= stt (min (+ stt int) ; if next point is beyond the end length
len))
(+ stt int) ; then use the beyond len which (while) does not pass
(min (+ stt int) ; else use middle point or max
len))))
(princ "\nWrong selection. Two LWPolylines are required.")
)
(princ)
)

 

My issue right now is that I would like to round the dimension to the nearest .5 and change the comma in the result to a decimal point. Also, when I don't input a string for my notation, rather than the R/W printing it just adds the footage mark.

Thank you for the swift reply.

0 Likes
Message 26 of 27

ВeekeeCZ
Consultant
Consultant

I've fixed the last one. The others are driven by your dimstyle.

 

(vl-load-com)

(defun c:AUTODIM ( / en1 en2 int len stt len pt1 pt2 prefix linty new dim newdimvalue)
  
  (if (and (setq en1 (car (entsel "\nSelect 1st polyline (dim from): ")))
	   (= "LWPOLYLINE" (cdr (assoc 0 (entget en1))))
	   (setq en2 (car (entsel "\nSelect 2nd polyline (dim to): ")))
	   (= "LWPOLYLINE" (cdr (assoc 0 (entget en2))))
	   (setq int (getdist "\nInterval: "))
	   (setq len (vlax-curve-getDistAtParam en1 (vlax-curve-getEndParam en1)))
	   (not (initget 4))
	   (setq stt (cond ((getreal "\nDistance at the beginning <0>: "))
			   (0)))
	   (not (initget 4))
	   (setq len (cond ((getreal (strcat "\nDistance at the end <Use the entire polyline = " (rtos len 2 2) ">: ")))
			   (len)))
	   (setq prefix "<>' ")
	   (setq linty (getstring T "\nWhat are you measuring to? <R/W>: "))
	   (setq linty (if (= linty "") "R/W" linty))
	   )
    (while (and (<= stt len)
		(setq pt1 (vlax-curve-getPointAtDist en1 stt))
		(setq pt2 (vlax-curve-getClosestPointTo en2 pt1)))
      (command-s "_.DIMALIGNED"
	"_none" (trans pt1 0 1)
	"_none" (trans pt2 0 1)
	"_none" (polar (trans pt1 0 1)
		       (+ (* 1.5 pi)
			  (angle (trans pt1 0 1) (trans pt2 0 1)))
		       1.5))
      (setq newdim (entlast))
      (setq newdimvalue (strcat prefix linty))
      (command "dimedit" "n" newdimvalue newdim "")
      (setq stt (if (= stt (min (+ stt int) ; if next point is beyond the end length
				len))
		  (+ stt int) ; then use the beyond len which (while) does not pass
		  (min (+ stt int) ; else use middle point or max
		       len))))
    (princ "\nWrong selection. Two LWPolylines are required.")
    )
  (princ)
  )
Message 27 of 27

stevor
Collaborator
Collaborator

A conventional offset distance is along a normal line from your reference line,

so a few more steps would be needed.

S
0 Likes