making distance

making distance

Anonymous
Not applicable
910 Views
14 Replies
Message 1 of 15

making distance

Anonymous
Not applicable

Dear Sir,

I am using AutoCAD 2013. I have some road layout & some gates & openings. I need to write every opening start & ending distance from centyer line start point. its more than 45 roads, there is too much openings & parkings. I am making distance for every opening, Centerline trim & checking then writing. Please any lisp for knowing distance of centerline from starting to required point. I attached an examble. please help me. 

0 Likes
911 Views
14 Replies
Replies (14)
Message 2 of 15

pbejse
Mentor
Mentor

@Anonymous wrote:

Dear Sir,

I am using AutoCAD 2013. I have some road layout & some gates & openings. I need to write every opening start & ending distance from centyer line start point. its more than 45 roads, there is too much openings & parkings. I am making distance for every opening,  Centerline trim & checking then writing.


Its a daunting task indeed, same goes for writing a lisp routine for to what you requested.

 


@Anonymous wrote:

 Please any lisp for knowing distance of centerline from starting to required point. I attached an examble. please help me. 


For this part its easy, ( i think ), better for you to post a drawing file, Is this drawing created in Civil 3D? I bet theres a feature there where you create a "custom" labels? 

 

0 Likes
Message 3 of 15

Anonymous
Not applicable

no, its not from civil3d. 

0 Likes
Message 4 of 15

pbejse
Mentor
Mentor

@Anonymous wrote:

no, its not from civil3d. 


Please do show the dimensions and labels on the drawing as well, saves us time ot figure out the Dimstyle and leader style.

 

Also, what all those figures meant. please describe what those represents. i.e R3/R4...

 

0 Likes
Message 5 of 15

Anonymous
Not applicable

R3/ R4 is distance from center line ti right side. I need to know the length from starting (0+0000) to requires point.

0 Likes
Message 6 of 15

pbejse
Mentor
Mentor

Well, you did include the labels, my bad i did not look hard enough.

 

At your sample drawing, it would have been easier if the ALL road centerline matches the direction of the stations. some of them are not.

 

With this short snippet, it will give you the distance from the STARTING point of the Polyline.

 

 

(defun c:demo (/ e p dist)
  (and (setq e (car (entsel "\nSelect road center line")))
       (setq p (getpoint "\nPick point for label:"))
       (setq dist (vlax-curve-getDistAtPoint
		    e
		    (vlax-curve-getclosestpointto e p)
		  )
       )
       (print (rtos dist 2 4))
  )
  (princ)
)

 

You can however fix the centerlines by reversing the direction.

 

HTH

0 Likes
Message 7 of 15

Anonymous
Not applicable

I did check the program, but not getting the answer..answer coming 0.00000

 

 

 

((((Command: DEMo
Select road center line
Pick point for label:
"0.0000"
Command:

0 Likes
Message 8 of 15

pbejse
Mentor
Mentor

@Anonymous wrote:

I did check the program, but not getting the answer..answer coming 0.00000 

 


Thats strange. works on my end with the sample drawing you posted.

I selected the centerline "CENTER LINE-02$0$AREA_6_PROPOSED CENTER LINE"

I selected the point of intersection at "0+975.911 (R/3.50)"

 

it give the result as 975.114

 

Is there by any chance the centerline in on an overlayed XREF? 

0 Likes
Message 9 of 15

Anonymous
Not applicable

Thanks ..... Its OK now

0 Likes
Message 10 of 15

pbejse
Mentor
Mentor

@Anonymous wrote:

Thanks ..... Its OK now


I see, good for you, now i can help you further if you want me to, from the result we can update the TEXT label and updating the value . Do you want us to proceed with that?

0 Likes
Message 11 of 15

pbejse
Mentor
Mentor

@Anonymous wrote:

Thanks ..... Its OK now


I see, good for you, now i can help you further if you want me to, from the result we can update the TEXT label and updating the value . Do you want us to proceed with that?

 

EDIT: This offer will expire in the next 10 minutes from now , my current time is 2:30 pm

0 Likes
Message 12 of 15

pbejse
Mentor
Mentor

@pbejse wrote:
EDIT: This offer will expire in the next 10 minutes from now , my current time is 2:30 pm

Ow well, since i'm such a nice guy [as i like to think so] I will post the code anyway 


Part of this routine is from this link Adding 0+ symbol by Kent Cooper  [station function]

 

 

(defun c:gdst (/ station e p p2 dist dist2 newstr)
;;; 		pBe Dec 201			;;;
  
;;;	Station function by Kent Cooper  	;;;
  (defun station (numstr)
    (setq intlen (strlen (itoa (atoi numstr))))
    (while (< intlen 4)
      (setq
	numstr (strcat "0" numstr)
	intlen (1+ intlen)
      )					; setq
    )					; while
    (strcat
      (substr numstr 1 (- intlen 3))
      "+"
      (substr numstr (- intlen 2))
    )					; strcat
  )
  (if (setq e (car (nentselp "\nSelect road center line")))
    (while (and	(setq p (getpoint "\nPick point for label:"))
		(setq txt (car (entsel "\nSelect label to update")))
	   )

      (setq dist (vlax-curve-getDistAtPoint
		   e
		   (setq p2 (vlax-curve-getclosestpointto e p))
		 )
      )
      (setq dist2 (distance p p2))
      (setq newstr (Strcat (station (rtos dist 2 3))
			   " (R/"
			   (rtos dist2 2 2)
			   ")"
		   )
      )
      (vla-put-textstring (vlax-ename->vla-object txt) newstr)
    )
  )
  (princ)
)

 

Command: GDST

Select road center line

[select the road center line once]


Pick point for label:
Select label to update

 

Pick point for label:
Select label to update

..........

 

You can continue to pick the point and text until you are done , i did notice a coupe of errors on the sample drawing such as

"0+304.326 (R/44.10)" that should've been 4.10. The routine above will help you avoid this.

 

But remember to reverse the direction of the road centerline that doesn't match the station start point.

 

HTH

 

0 Likes
Message 13 of 15

_Tharwat
Advisor
Advisor

Just to avoid any error message if a user picked something else other than (m)text . 😉

 

(setq txt (car (entsel "\nSelect label to update")))
(wcmatch (cdr (assoc 0 (entget txt))) "TEXT,MTEXT")

 

0 Likes
Message 14 of 15

pbejse
Mentor
Mentor

That would help too tharwat Smiley Happy

0 Likes
Message 15 of 15

Anonymous
Not applicable

Thanks

0 Likes