Reformate string for chainage

Hi,

What would be the best way to reformat a list of strings such as:
10.12345
100.12345
1000.12345

Into Station or Chainage typical format
0+10.12
1+00.12
10+00.12

Basically I need to insert a “+” two digits to the left of the decimal point.

Any help is appreciated, thanks

1 Like

Python

5 Likes

Civil 3D Toolkit

4 Likes

Thank you Paulo for the quick response. I am not finding the Civil Toolkit package to download. Is this something you are working on, or is it available already and I am missing a step to install it?

Will be available after AU, for now happy Python :slight_smile:

Hi @marshmallow ,

Alternative approach using basic nodes.
StnFormat.dyn (24.2 KB)

Hi @Paolo_Emilio_Serra1 ,
Nice python and package (Civil 3D Toolkit)

Cheers,
Jowenn

3 Likes

@Paolo_Emilio_Serra1 ,
thanks for the python code, looks a little intermediating to me but time to learn something new. It seems like you’re holding on to some great new functionality in the Toolkit for a big reveal in AU.

Thanks @JowennLua, your graph is very similar to how I addressed it, but it seemed like a very long operation for me!

That’s the spirit!

Hi @marshmallow ,

Can be converted to code to make it not that long. Just want to show the long method. Here’s the converted method. I’m not sure how to code the number to string so I left it as is. StnFormat_Code.dyn (9.8 KB)

Cheers,
Jowenn

4 Likes

I installed the Civil 3D toolkit and used the MText.StationFormatting and it was exactly what I needed. Nice Work and thank you, thank you, thank you!

2 Likes

Hi!
New to Dynamo and I’m up to create my first graph.
First post in this excellent forum seems to be a reply :slight_smile:

In Sweden we type Station Formatting, for Road 1/234.567, and for Rail 1+234.567.
Can this be done on the Civil 3D Toolkit - StationFormatting node or does it need to be done using Python coding?
Best regards,
Patrick

Did some changes to you code @JowennLua and now I think it work fine for my purpose and add a dash ”/” instead of + and set chainage to be shown as 1/234.567 instead of 12/34.567

Thanks for the good script
StnFormat_Code_1+123.dyn (10.1 KB)

1 Like

@JowennLua What language is the code in your graph? Is it C#?
Asking because I couldn’t find String.Insert in Python translater. Maybe it’s because of my skills

Then, I wonder how to write the code if I would like to be able to choose if I want decimals or not. Is there a way to make it user defined if user want 1, 2 or 3 decimals?

Anything in a Code Block is DesignScript.

1 Like

Thanks @mzjensen .
When should I use DesignScript and when should I use Python?
Regards,
Patrick

I was about to launch off into a long post, but I think this video covers everything anyway!

3 Likes