Revit, Dynamo, String.PadLeft issue

Hello!
Making Mark numbers, need 01,02,03,04,05,06,07,08,09,10,11,12,13… instead of 1,2,3,4,5,6,7,8,9,10,11,12,13… what I am doing wrong?

I believe this is a known issue with the display of strings which forces the formatting of the display to what you are seeing. Should be fixed in an updated build.

Try using a String.Join to see what happens if you put a carriage return in between each of the values.

Slightly inconsistent conversion from number to string…

Hope that helps,

Mark

Looks perfect, but I dont understand why its not working for me

Maybe easiest using Python…

OUT = [str(num).zfill(2) for num in IN[0]]

4 Likes

try with this example…

1 Like

Everyone is overcomplicating this with python in my opinion. Sure the python is 1 line of code, but this can actually be solved with Dynamo nodes only

You have 2 options:

  • Try String.FromObject from the Crumple package. It has a built in function to remove trailing 0’s when converting numbers.

  • If for some reason you don’t want to use packages, use a List.Flatten after the String.Split. Also make sure to use String.Length and then use the code block to add 1 to the total string length.
    (Like the example above)

  • Bonus: I actually use List.Count before using String.Length. That way you can let the list determine how many 0’s you need in front (say you need 001-100 or 0001-1000 etc)
    Hope that helps.

yeah i would just try convert the numbers to integer with floors or ceiling as @sjafarali75 show…guess it should work

1 Like

Never noticed it’s a way to convert numbers to integer (datatype wise). That’s awesome!

yeah many ways it can be done…Dynamo Dictionary

hi


cordially
christian.stan

2 Likes

Hi Christian…yeah guess its depends if it a double or integer

1 Like

hi, a

conditionnal
DSCore.Object.Type(a)=="SystemInt64"?
a+"":
Math.Floor(a)+"";

to remove doubts :wink:


cordially
christian.stan

1 Like

Dosent work for me

Aso this dosent work


l

are you in revit 2023 ?

2024

As I noted before, I believe you are missing an update so Dynamo is padding the values out but only in the display.

Try joining the values into one string, or writing out to a text file to confirm.

1 Like

Yeah @jacob.small guess you are right :wink: the good old issue i have try to forget :wink:

hi,
try this
OUT = [str(int(num)).zfill(2) for num in IN[0]]
cordially
christian.stan

1 Like