LISP changing to station from chainage

LISP changing to station from chainage

Anonymous
Not applicable
5,584 Views
10 Replies
Message 1 of 11

LISP changing to station from chainage

Anonymous
Not applicable

So I have about 20km of road that I need to put a chainage on and have the lisp that is attached.

 

Everything looks fine until it comes up to the 1km mark and changes from CH0+000 to sta. 0+000.

 

This isn't my LISP and and i've had a look around and it's just too complex for me.

 

If anyone could help me out, it would be much appreicated.

0 Likes
Accepted solutions (1)
5,585 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution
How about find "sta:" and replace it with "CH"?
Easy peasy.
0 Likes
Message 3 of 11

john.uhden
Mentor
Mentor

Or run it through a US to Australian translator.  :]

John F. Uhden

0 Likes
Message 4 of 11

Anonymous
Not applicable

Yup, it was as easy as that.

 

Thanks.

0 Likes
Message 5 of 11

trumankiko
Advocate
Advocate

can someone help? my drawing zooms far out after i run the code. also, i want to make my stationing like this format:

STA. 0+000.00

STA. 0+020.00

thanks! ♥

 

0 Likes
Message 6 of 11

rolisonfelipe
Collaborator
Collaborator

try it!

Message 7 of 11

trumankiko
Advocate
Advocate

hi. thanks for this but it doesn't do everything i said i wanted to be done using the code. i want all the stationing to be labeled with "STA." and not "CH:". also i wanted my number format to be STA. 0+000.00 and then when i add the increment (20000 in my case) the next station should be STA. 0+020.00 and so on until it reaches STA. 0+980.00. Then the next station should be STA. 1+000.00 then STA. 1+020.00. thanks! ♥

0 Likes
Message 8 of 11

Sea-Haven
Mentor
Mentor

For trumankiko "STA." and not "CH:" look at line 155 Not Tested.

0 Likes
Message 9 of 11

trumankiko
Advocate
Advocate

thanks! i had this already changed but how about the number format?

0 Likes
Message 10 of 11

john.uhden
Mentor
Mentor

@trumankiko ,

I've posted this before...

(defun @FormatSta (sta xp prec / n sign str)
     ;; where:
     ;;  sta = real or integer
     ;;  xp = exponent of 10 to specify how many numeric characters between "+" and "."
     ;;  prec = decimal precision
     (setq n (expt 10.0 xp))
     (setq sign (if (minusp sta) "-" ""))
     (setq sta (abs sta))
     (setq str1 (strcat sign (itoa (fix (/ sta n))) "+"))
     (setq str2 (rtos (* n (rem (/ sta n) 1)) 2 prec))
     (repeat (max (- xp (strlen str2))(- xp (vl-string-position 46 str2)))
       (setq str2 (strcat "0" str2))
     )
     (strcat str1 str2)
   )
For example:
Command: (@formatsta 123.45 2 2)
"1+23.45"

Command: (@formatsta 123.45 3 3)
"0+123.450"
;| Of course if you already have stationing/chainage text, then we have
to extract the numeric value and format it properly.  This is just a
simple example based on one type of typical formatting
|;

(defun c:CHGFORMAT ()
  ;; It can change "CH 1+23.45" to "STA 0+123.450"
  (setq ss (ssget "X" '((0 . "TEXT")(1 . "CH #*"))))
  (repeat (setq i (sslength ss))
    (setq e (ssname ss (setq i (1- i)))
          ent (entget e)
          old (cdr (assoc 1 ent))
          old (substr old 3) ;; remove "CH " prefix
          old (distof (vl-string-subst "" "+" old))
          new (strcat "STA " (@formatsta old 3 3))
    )
    (entmod (subst (cons 1 new)(assoc 1 ent) ent))
  )
  (princ)
)

 

John F. Uhden

0 Likes
Message 11 of 11

cde032
Observer
Observer

The end chainage is not corrected and I think the end chainage should be used the whole length to instead.

0 Likes