split numbers and insert characters "+"

split numbers and insert characters "+"

kajanthangavel
Advocate Advocate
1,600 Views
16 Replies
Message 1 of 17

split numbers and insert characters "+"

kajanthangavel
Advocate
Advocate

I make a lisp for chainage marker. but i want to put "+" character in intro the number.

Ex:

Lisp make like this

5560.256

10201.250

15020.000

 

But I want like this

5+560.256

10+201.250

15+020.000

Please somebody help for modify this lisp code.

(defun c:ch (/ p1 ptx ro)
(setq P1 (getpoint "\nPick Chainage: "))
(setq ptx (car p1))
(setq ro (* 90 (/ pi 180)))
            (progn
              (entmakex
                (list (cons 0 "TEXT")
                      (cons 40 0.1)
                      (cons 10 p1)
                      (cons 50 ro)
                      (cons 1 (strcat (rtos ptx 2 3)))
                )
              )

            )
(princ)
)
0 Likes
Accepted solutions (1)
1,601 Views
16 Replies
Replies (16)
Message 2 of 17

ВeekeeCZ
Consultant
Consultant

Just simply... hopefully understandable.

 

(defun ch+ (n / dz str len)
  (setq dz (getvar 'dimzin))
  (setvar 'dimzin 0)
  (setq str (rtos n 2 3))
  (setq len (strlen str))
  (setvar 'dimzin dz)
  (if (> len 7)
    (strcat (substr str 1 (- len 7)) "+" (substr str (- len 6)))
    str))
0 Likes
Message 3 of 17

dbhunia
Advisor
Advisor
Accepted solution

You also can try this....... 

 

(defun c:ch (/ p1 ptx ro ptx_len)
(setq P1 (getpoint "\nPick Chainage: "))
(setq ptx (car p1))
(setq ptx (strcat (rtos ptx 2 3)))
(setq ptx_len (strlen ptx))
(setq ro (* 90 (/ pi 180)))
(if (and (> ptx_len 7) (/= "-" (substr ptx 1 (- ptx_len 7))))
    (setq ptx (strcat (substr ptx 1 (- ptx_len 7)) "+" (substr ptx (- ptx_len 6))))
)
(progn
    (entmakex
	(list (cons 0 "TEXT")
	   (cons 40 0.1)
	   (cons 10 p1)
	   (cons 50 ro)
	   (cons 1 ptx)
        )
    )
)
(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 4 of 17

john.uhden
Mentor
Mentor
   (defun @FormatSta (sta xp prec / n sign str)
     ;; where:
     ;;  sta = real or integer
     ;;  xp = exponent of 10 to specify how many numeric charcters 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 56234.56 3 2)
"56+234.56"

Command: (@formatsta 56234.56 2 3)
"562+34.560"

John F. Uhden

Message 5 of 17

pbejse
Mentor
Mentor

@john.uhden wrote:

For example:

Command: (@formatsta 56234.56 3 2)
"56+234.56"

Command: (@formatsta 56234.56 2 3)
"562+34.560"


 

John,

Is there an industry standard for stationing?  when do you use  "56+234.56"  for 56234.56 and when is it "562+34.560"? Not a civil guy so... 🙂

 

.

 

 

0 Likes
Message 6 of 17

john.uhden
Mentor
Mentor
It is customary that metric uses thousands of meters, but imperial uses
hundreds of feet. Metric uses "chainage" and imperial uses "station."
Metric is usually 3 places after the decimal and imperial 2 places.
In the US (and maybe elsewhere), a chain was 66 feet long and consisted of
100 links.
A rod was 1/4 of a chain, or 16.5 feet.
Thus you will find many old road rights of way to be 2 rods, 3 rods, or 4
rods wide.

John F. Uhden

Message 7 of 17

dlanorh
Advisor
Advisor

and one acre is 160 sq rods. If anyone tells you they were the good old days, beat them into submission with the rod before wrapping them in the chain. Robot tongue

I am not one of the robots you're looking for

Message 8 of 17

john.uhden
Mentor
Mentor
I love it!

John F. Uhden

0 Likes
Message 9 of 17

pbejse
Mentor
Mentor

@john.uhden wrote:
It is customary that metric uses thousands of meters, but imperial uses
hundreds of feet. Metric uses "chainage" and imperial uses "station."
Metric is usually 3 places after the decimal and imperial 2 places.

Cool beans.

 

Thank you for the info John,  the system variable MEASUREMENT would be the ideal reference for determining the as to when to use 3 or 2 places after the decimal then.

 

cheers

 

 

0 Likes
Message 10 of 17

john.uhden
Mentor
Mentor
That's very clever, if people actually use it.
I should at least include it as the default values.

John F. Uhden

0 Likes
Message 11 of 17

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:
.... a chain was 66 feet long and consisted of 100 links.  A rod was 1/4 of a chain, or 16.5 feet. ....

 

In some cases it can get >even weirder< ....

Kent Cooper, AIA
0 Likes
Message 12 of 17

dbroad
Mentor
Mentor

Based on the initial code and the solution credited, I am curious, do all roads in India run west to east starting from 0 degrees longitude? 🙂 

 

I say this because, in my experience, stationing is measured along a route. Routes rarely begin at a coordinate origin. They begin at the POB.  They also rarely run straight east forever from the origin.  I would think that a better approach than picking a point and keeping only its x-value would be to pick a polyline path and then pick a point on that path.  The stationing would be the distance along the path.

 

..Just saying...

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 13 of 17

dbhunia
Advisor
Advisor

Hi @dbroad I think you better know the answer of "do all roads in India run west to east starting from 0 degrees longitude?"  ..... 

 

What it can be?

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 14 of 17

john.uhden
Mentor
Mentor
Do you mean Centigrade or Fahrenheit?

John F. Uhden

0 Likes
Message 15 of 17

dbhunia
Advisor
Advisor

No I want to mean Geometrifying Trigonometry. 

 

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 16 of 17

ВeekeeCZ
Consultant
Consultant

Hey guess, this is not fair.

I'm the one who you should blame for this poor solution. The guy is innocent, he just copy-pasted my poor suggestion. It's not his fault! I take full responsibility for my doing. I promise, that next time I'll be in India, I'll personally take a look whether I could possibly find any road not going east-west and let you know!

0 Likes
Message 17 of 17

john.uhden
Mentor
Mentor

You should follow one of Yogi Berra's pieces of advice... "If you come to a fork in the road, take it."

John F. Uhden

0 Likes