Remove trailing zeros

 

Hi Andreas Dieckmann,

I have tried out your instruction, it is useful
Also, I would like to raise another case for you to brainstorm
It would be much more perfect if you have a solution for the case shown below as well

Many thanks

Trim Trailing Zeros

 

 

 

To those who want to trim trailing zeros same as my case
By utilizing available nodes in conjunction with Andreas’s advice, I have found a workaround for this issue finally
So I should now put an end to this topic
However, any better idea would be greatly appreciated
Trim Trailing Zeros

Hi,

If you got those trailing 0’s by using Dynamo’s “String from Object” node, maybe a neater solution would be to try Python’s number to string conversion:

2015-06-08_10-48-40

3 Likes

Dimitar,

Extremely smooth!!
It’s a lot better than my clumsy set of nodes
Your python script has just let me know that I am newbie
Thanks for your kind sharing

 

 

 

Very good code, Dimitar.

the Python’s number to string conversion seems keep 1 zero direct after the decimal point, is there a way to resolve this problem?

Trim-Trailing-Zeros-Python-result

Hi Chen,

I rolled a revised version of the above called “Number.ToString” into spring nodes package. Give it a try:

2016-05-12_11-12-58

2 Likes

Thanks Dimitar! It works perfect.

3 Likes

@Dimitar_Venkov

I haven’t touched Dynamo for a year since my first plunge into this marvelous tool and this community and I’m just restarting to get my feet back in the game…

I’m running Dynamo 1.2.1.3083 on Revit 2016 and used the “Number.ToString” node but it doesn’t seem to remove the zeros like in your post to Chen back in May '16.

My Attempt
Parameter Value is my L/s (metric model) flow converted to Cubic Feet/seconds (by Revit/Dynamo) which I want to convert back to L/s but with no trailing zeros:

Thanks,
Jonathan

Hi,
Looks like you’ll first have to round up your numbers to appropriate for your need.

Hi @Jonathan_Roy

Why not just convert to Revit Internal Units.

Here is the DYN file For Jonathan (IneternalParameterUnits).dyn (3.2 KB)

1 Like

Hi,
Thanks for the different solutions and I tried them out with different results.

I first tried @Kulkul’s solution with the python script and it gave me what I was looking for as an end solution. The “how did he get that answer?” in me still remains clueless when I quickly open the python script to take a look. I guess I’ll have to disect it later with the “Revit Lookup” addin you pointed me too a while back to try and understand what is going on.

Then I tried @Dimitar_Venkov’s suggestion regarding rounding up. I only found the “Math.RoundUpToPrecision” node in the packages I have installed, but I didn’t like the results for my application.
To follow the same idea, I then looked up “Rounding” on the forum and found a 2015 Thread about the subject that @Kulkul had brought up and tried the soluon provided by @john_pierson. It also gave me a good solution and since the package is made up of OOTB nodes I think :wink: I’d be able to understand how he was able to make it.

I’ll close by saying that someone has to make a MEP Python 101 class. I’m pretty sure it would be popular and in demand. I know I would, because we’re looking to do more engineering with Revit than is possible with OOTB .

1 Like

@Jonathan_Roy Next time start a new thread. Thanks :slight_smile:

Will do. I wasn’t sure if i should start a new thread on the same subject or continue on this one since it was in the same direction. I should’ve started a new one and linked the different posts in them?
Thanks again, and see you on a new thread… soon :wink:

1 Like

For what you’re trying to do, getting Revit’s display unit value makes a lot more sense, so I’d go for Kulkul’s suggestion. But for future reference, if you’re trying to get the string representation of a floating point number, my suggestion was this:

2 Likes

Thank you Dimitar, this helped me today as well!

Hi Andreas,
Would you mind sharing a larger image of your method for removing 0’s with varying lengths of trailing 0’s in dynamo? I found this older post of yours and was able to read very little of the image.

Many thanks, this information will be quite useful.

Images should show full size when checking them out in the old forum.

http://dynamobim.org/forums/topic/remove-trailing-zeros/

2 Likes

Thank you Ewan. Was not aware of the old forum, having just recently gotten into Dynamo myself. Your assistance is quite appreciated!

1 Like

Hello @all,
Many thanks for your help and advice in this topic.
Is there a ways to define the number of trailing Zeros?

String.Replace gives me five trailing zeros, even though I define “0000” to be replaced with “”

Springs.Number.ToString gives me nothing after the decimla place when trailing zeros are present - I’d like to always show three numbers after the decimal point.

Is this possible?

Many thanks in advance