Jump to content

coordinates of centerline and both side offsets


anindya

Recommended Posts

i have attached a sample drawing,where i have an alignment and segment of 20M.I need a result of center line and offset as mentioned.can it possible by any ways,by lisp or vba.it will be too much usefull to many of us like me.i need it too much.then i can save my too much time and avoid mistake .pls help me

PRAC.dwg

Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • anindya

    9

  • Hippe013

    7

  • ymg3

    4

  • BIGAL

    3

Top Posters In This Topic

Give this a try. It doesn't have much for error trapping, but gets the job done.

 

(defun c:test ()
 (setq sel (entsel "\nSelect Centerline Alignment: "))
 (if sel
   (progn
     (setq obj (vlax-ename->vla-object (car sel)))
     (setq sta (getreal "\nEnter Station Distance: "))
     (if sta
(progn
  (setq cl-pol (vlax-curve-getPointAtDist obj sta))
  (setq los (getreal "\nEnter Left Offset Distance: "))
  (setq ros (getreal "\nEnter Right Offset Distance: "))
  (if (and los ros)
    (progn
      (setq fd (vlax-curve-getFirstDeriv obj (vlax-curve-getparamAtPoint obj cl-pol)))
      (setq angR (- (angle '(0 0 0) fd) (* pi 0.5)))
      (setq angL (+ (angle '(0 0 0) fd) (* pi 0.5)))
      (setq pR (polar cl-pol angR ros))
      (setq pL (polar cl-pol angL los))
      (BTH:dro cl-pol 5)
      (BTH:drx pR 1)
      (BTH:drx pL 3)
      (grdraw cl-pol pL 3)
      (grdraw cl-pol pR 1)
      (princ "\n**********************************")
      (princ (strcat "\nCenterline Station: " (rtos sta 2 2)))
      (Princ (strcat "\nNorthing: " (rtos (cadr cl-pol) 2 2)
		     "  Easting: " (rtos (car cl-pol) 2 2)))
      (princ "\n**********************************")
      (princ (strcat "\nLeft Offset Distance: " (rtos los 2 2)))
      (princ (strcat "\nNorthing: " (rtos (cadr pL) 2 2)
		     "  Easting: " (rtos (car pL) 2 2)))
      (princ "\n**********************************")
      (princ (strcat "\nRight Offset Distance: " (rtos ros 2 2)))
      (princ (strcat "\nNorthing: " (rtos (cadr pR) 2 2)
		     "  Easting: " (rtos (car pR) 2 2)))
      (princ "\n**********************************")
      )
    )
  )
)
     )
   )
 (princ)
 )


(defun BTH:drx (ctr clr / COR1 COR2 COR3 COR4 VS XS XS2)
 (setq vs (getvar "viewsize"))
 (setq xs (/ vs 20))
 (setq xs2 (/ xs 2))
 (setq cor1 (polar ctr (* pi 0.25) xs2))
 (setq cor2 (polar ctr (* pi 0.75) xs2))
 (setq cor3 (polar ctr (* pi 1.25) xs2))
 (setq cor4 (polar ctr (* pi 1.75) xs2))
 (grdraw ctr cor1 clr 0)
 (grdraw ctr cor2 clr 0)
 (grdraw ctr cor3 clr 0)
 (grdraw ctr cor4 clr 0)
 )





(defun BTH:dro (ctr clr / COR0 COR1 COR10 COR11 COR12 COR13 COR14 COR15 COR16 COR17 COR18 COR19 COR2 COR3 COR4 COR5 COR6 COR7 COR8 COR9 VS XS XS4)
 (setq vs (getvar "viewsize"))
 (setq xs (/ vs 20))
 (setq xs4 (/ xs 4))
 (setq cor0 (polar ctr 0 xs4))
 (setq cor1 (polar ctr (* pi 0.1) xs4))
 (setq cor2 (polar ctr (* pi 0.2) xs4))
 (setq cor3 (polar ctr (* pi 0.3) xs4))
 (setq cor4 (polar ctr (* pi 0.4) xs4))
 (setq cor5 (polar ctr (* pi 0.5) xs4))
 (setq cor6 (polar ctr (* pi 0.6) xs4))
 (setq cor7 (polar ctr (* pi 0.7) xs4))
 (setq cor8 (polar ctr (* pi 0. xs4))
 (setq cor9 (polar ctr (* pi 0.9) xs4))
 (setq cor10 (polar ctr pi xs4))
 (setq cor11 (polar ctr (* pi 1.1) xs4))
 (setq cor12 (polar ctr (* pi 1.2) xs4))
 (setq cor13 (polar ctr (* pi 1.3) xs4))
 (setq cor14 (polar ctr (* pi 1.4) xs4))
 (setq cor15 (polar ctr (* pi 1.5) xs4))
 (setq cor16 (polar ctr (* pi 1.6) xs4))
 (setq cor17 (polar ctr (* pi 1.7) xs4))
 (setq cor18 (polar ctr (* pi 1. xs4))
 (setq cor19 (polar ctr (* pi 1.9) xs4))
 (grdraw cor0 cor1 clr 0)
 (grdraw cor1 cor2 clr 0)
 (grdraw cor2 cor3 clr 0)
 (grdraw cor3 cor4 clr 0)
 (grdraw cor4 cor5 clr 0)
 (grdraw cor5 cor6 clr 0)
 (grdraw cor6 cor7 clr 0)
 (grdraw cor7 cor8 clr 0)
 (grdraw cor8 cor9 clr 0)
 (grdraw cor9 cor10 clr 0)
 (grdraw cor10 cor11 clr 0)
 (grdraw cor11 cor12 clr 0)
 (grdraw cor12 cor13 clr 0)
 (grdraw cor13 cor14 clr 0)
 (grdraw cor14 cor15 clr 0)
 (grdraw cor15 cor16 clr 0)
 (grdraw cor16 cor17 clr 0)
 (grdraw cor17 cor18 clr 0)
 (grdraw cor18 cor19 clr 0)
 (grdraw cor19 cor0 clr 0)
 )

Link to comment
Share on other sites

Respected sir i have tried that one but it does not give the desired result.i need the coordinates of centerline and both side offset in the table format.i have modified the question for understanding purpose.please help me.It is very time taking in another way and a unavoidable work to many of us like me.

PRAC1.dwg

Link to comment
Share on other sites

What you are asking for is certainly possible. Though it will take quite a bit work to merge and format the cells. I could write a lisp to accomplish this, though it will take some time.

 

regards,

 

hippe013

Link to comment
Share on other sites

Hippe013 had a look at what you had done and was interested as simple offset routine , a couple of obvious things jumped out, the easy one is just imply a spacing and loop for multiple distances. Now the harder one is a setout sequence would always have the tangent pts or change in directions in the correct order also these would be the pline vertices, maybe work out a list of chainages 1st, this has advantage of adding individuals also to a fixed spacing. Need options like table or csv. I have played a little bit with generating tables its not that hard. I am may have some time next week so will try to do the repeat and add chainages. last one to think about is change directions say 45 degrees setout before, 1/2 or end or both S & E.

 

Ch 0.0 LXYZ R XYZ

CH 12.35 is a tangent pt LXYZ RXYZ

CH 20 LXYZ RXYZ

CH 22.35 is a tangent pt LXYZ RXYZ

CH 30 LXYZ RXYZ

Link to comment
Share on other sites

respected sir i know that i can have that from friends like bigal sir and hippe013 sir, so i can wait ,no problem.but it will helpful too much if it has been done.

Link to comment
Share on other sites

Hippe013 will have time next week to play a couple of things Vl returns length of pline so spacing can make list of distances, (10 20 30 40 50)

Then co-ords of pline as distance (0.0 12.35 37.86 42.35 52.3)

Then your STA is each value in the new list (0.0 10 12.35 20 30 37.86 40 42.35 50 52.3) rather than asking for each one.

Maybe then ask extra ch's also STA list (0.0 10 12.35 20 30 33.5 37.86 40 42.35 44.0 50 52.3)

Link to comment
Share on other sites

anindya,

 

First time I see a road alignment that is a spline

all the way, without horizontal curve and/or straight segment.

 

The following subroutine will return all the data required

to fill the table in list form.

 

(offsetlist)

 

(("0+000.000" (13.8431 17.8482 0.0) (13.8774 12.8483 0.0) (13.9117 7.84839 0.0))

("0+010.000" (23.0786 18.3023 0.0) (23.855 13.363 0.0) (24.6315 8.42363 0.0))

("0+020.000" (26.7663 19.8929 0.0) (31.6081 18.6451 0.0) (36.4499 17.3972 0.0))

("0+030.000" (27.3506 29.469 0.0) (32.2751 28.6029 0.0) (37.1995 27.7369 0.0))

("0+040.000" (37.2184 39.9877 0.0) (38.9641 35.3024 0.0) (40.7099 30.6171 0.0))

("0+045.866" (43.3021 41.8123 0.0) (44.5829 36.9791 0.0) (45.8636 32.1459 0.0)))

 

The filling, I leave to you as an exercise.

 

(defun offsetlist (/ en ent offl offr intv dtot dlst clst alst llst rlst olst)
  (setq en   (car (entsel))
        ent  (entget en)
        offl 5.00
        offr 5.00
        intv 10.0         
        dtot (vlax-curve-getDistAtPoint en (vlax-curve-getendpoint en)) 
        dlst (append
                (in_range 0 dtot intv)
                (list dtot)
             )
        clst (mapcar '(lambda (a) (vlax-curve-getPointAtDist en a)) dlst)
        alst (mapcar '(lambda (a) (angleatpoint en a)) clst)
        llst (mapcar '(lambda (a b) (polar a (+ b (/ pi 2)) offl)) clst alst)
        rlst (mapcar '(lambda (a b) (polar a (- b (/ pi 2)) offr)) clst alst)
        olst (mapcar '(lambda (a b c d) (list (rtosta a 2 3) b c d)) dlst llst clst rlst)
   )
)   
   

  

;;                                                                            ;
;; Return angle along curve, at specified point (on curve)                    ;
;; e - valid curve (ENAME or VLA-OBJECT)                                      ;
;; p - point on curve                                                         ;
;; Alan J. Thompson, 11.04.10                                                 ;
;;                                                                            ;

(defun AngleAtPoint (e p)
  (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e p)))
)  
   

;;                                                                            ;
;; in_range      by ElpanovEvgeniy       (recursive)                          ;
;;                                                                            ;
;; Similar to the Python Function                                             ;
;;                                                                            ;

(defun in_range (s e i)
  (if (or (and (> i 0) (< s e)) (and (< i 0) (> s e)))
     (cons s (in_range (+ i s) e i))
  )
)


;;                                                                            ;
;; rtosta                     by ymg            September 2013                ;
;;                                                                            ;
;; Arguments:   sta, Real number to format as a Station                       ;
;;             unit, 1 for Imperials,                                         ;
;;                   2 for Metrics.                                           ;
;;             prec, Integer for number of decimals                           ;
;; DIMZIN must be set to 0 or 1 outside this routine.                         ;
;;                                                                            ;
;; Examples: (rtosta 0 1 0)  -> "0+00"   (rtosta 1328.325 1 2) -> "13+28.33"  ;
;;           (rtosta 0 2 0)  -> "0+000"  (rtosta 1328.325 2 2) -> "1+328.33"  ;
;;                                                                            ;
;; If sta is negative, format is as follow:                                   ;
;;                             (rtosta -1328.325 1 2) -> "13-28.33"           ;
;;                             (rtosta -1328.325 2 2) -> "1-328.33"           ;
;;                                                                            ;

(defun rtosta (sta unit prec / str a b dz)     
  (setq str (rtos (abs sta) 2 prec))    
  (while (< (strlen str) (if (= prec 0) (+ unit 2) (+ prec (+ unit 3))))
     (setq str (strcat "0" str))
  )
  (setq a (if (= prec 0) (- (strlen str) unit) (- (strlen str) prec (+ unit 1)))
        b (substr str 1 (- a 1))
        a (substr str a)
  )
  (strcat b (if (minusp sta) "-" "+") a)
)

 

ymg

Link to comment
Share on other sites

Has anyone even looked at the code that I attached!!!??? Table Alignment.lsp asks for user to select alignment and builds a table of coordinates. It seems as if my post has been overlooked!

Link to comment
Share on other sites

@ anindya,

 

Simply type (offsetlist) including parentheses.

 

@ Hippe013,

 

I did look, and yours do the job also.

But I believe the OP wants a canned solution.

 

ymg

Link to comment
Share on other sites

hippe 013 sir when i use your lisp i did not get any coordinates on the table,and after zooming the offsets drawn also disappear.THIS MESSAGE IS COMING,

Command: altable

Select Alignment Object:

Enter Station Interval: 10

Enter Left Offset Distance: 12

Enter Right Offset Distance: 18

Select Insertion Point for Table: ; error: Automation Error. Key not found

i need the coordinates on table of center and both side offsets,

Link to comment
Share on other sites

Anindya,

 

Create a new drawing with a regular acad.dwt template and draw a simple spline and then run the command.

 

Does it still error out? I can't think right now as to what the bug would be. Can you post the dwg that you are trying to run the command in? I created a new drawing and created a spline and ran the command. It worked for me. If you are able to post a drawing where the command doesn't work maybe I can pin point where the error occurs.

 

As for the offsets they are drawn graphically and are supposed to go away when you zoom.

 

regards,

 

hippe013

Link to comment
Share on other sites

HIPPE SIR THAT IS THE PROBLEM I AM SENDING YOU AN EXAMPLE WITH ATTACHED DWG.

 

Alignment Table.lsp Loaded Successfully. Type ALTABLE to begin.

Command:

Command: altable

Select Alignment Object:

Enter Station Interval: 10

Enter Left Offset Distance: 22

Enter Right Offset Distance: 33

Select Insertion Point for Table: ; error: Automation Error. Key not found

 

 

 

THAT JUST AN EXAMPLE.I WANT TO RUN THAT ON ANLIGNMENT BOTH STRAIGHT & CURVE IF IT IS POSSIBLE....

NEED HELP 1213.dwg

Link to comment
Share on other sites

respected ymg3 sir the lisp i got from you is fine but here if i have to change the offset then i have to change the routine and i have to modify it with new offset distance and can i get the result in excel or in any table format where there the data will be separated with chainage,left offset coord,center line coord, then right side coord as head line.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...