Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

code in distances as stations

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
FSJ_Mo
647 Views, 7 Replies

code in distances as stations

I have a lisp program that uses a 3dpoly to draw a profile of existing ground elevations. Currently, the program only writes in distances as whole numbers (ie:500 or 1600) I would like it to write them as stations along the profile (ie: 0+500  or 1+600) does anyone have a peice of code for doing this?

I run civil3d2012, but most of the rest of the office uses map3d2012

map3d2012 and civil3d2012

7 REPLIES 7
Message 2 of 8
_Tharwat
in reply to: FSJ_Mo

You can use the function strcat to add any string you want ,
e.g. (strcat "0+" "500)
Message 3 of 8
rkmcswain
in reply to: FSJ_Mo
Message 4 of 8
Kent1Cooper
in reply to: FSJ_Mo


@FSJ_Mo wrote:

I have a lisp program that uses a 3dpoly to draw a profile of existing ground elevations. Currently, the program only writes in distances as whole numbers (ie:500 or 1600) I would like it to write them as stations along the profile (ie: 0+500  or 1+600) ....


If the program already derives text strings representing integer values, and it's just a matter of converting them to stationing format, try incorporating something like this:

 

(defun station (num)
  (while (< (strlen num) 4)
    (setq num (strcat "0" num))
  ); while
  (strcat
    (substr num 1 (- (strlen num) 3))
    "+"
    (substr num (- (strlen num) 2))
  ); strcat
); defun

 

Usage:

 

Command: (station "500")
"0+500"

Command: (station "1600")
"1+600"

Command: (station "45")
"0+045"

Command: (station "123456")
"123+456"

Command: (station "1")
"0+001"

 

[You would presumably feed in a variable containing the text string, set as the result of what the other program works out, rather than text strings explicitly.]

 

If you ever need to go beyond six digits, that could be accomplished, but it would require adjustments.

Kent Cooper, AIA
Message 5 of 8
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
.... 

If you ever need to go beyond six digits, that could be accomplished, but it would require adjustments.


That is, if numbers beyond six digits need additional plus signs in them, such as 1+234+567 [I don't know how these things work, being a mere Architect -- I'm just manipulating text here].  If such a value would ever be encountered but still needs only the one plus sign to separate the last three digits, then the routine works as posted:

 

Command: (station "1234567")
"1234+567"

Kent Cooper, AIA
Message 6 of 8
FSJ_Mo
in reply to: Kent1Cooper

thanks for all the help guys!

Message 7 of 8
Kent1Cooper
in reply to: FSJ_Mo


@FSJ_Mo wrote:

thanks for all the help guys!


You're welcome.  Just for my own curiosity, do stationing numbers ever get to be 7 digits or more, and if so, would they need to have additional + signs separating groups of 3, like commas separating units from thousands from millions?  I'd like to have a little more inkling of how they're used, since questions involving them come up here now and then.

Kent Cooper, AIA
Message 8 of 8
FSJ_Mo
in reply to: Kent1Cooper

We are a survey company servicing mostly the oil & gas industry in NE British Columbia and our projects are usually under 20Km long so we would have no need. A project would have to be over 1000Kms long before this would apply and typically a project of this length would be broken into smaller segments. IMO

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost