Creating a Dynamo script in Revit to format a parameter value as a 4-digit string with leading zeros based on its numeric value

Hello everyone,

I’m working on a Revit family that has a parameter called “STG_PHOTO 360”, whose value can range from “1 to 2000”.
I’d like to create a Dynamo script that does the following:

  1. Find the “STG_PHOTO 360” parameter in the family.
  2. Check the value of this parameter
  3. If the value is less than 100, add “00” as a prefix.
  4. If the value is less than 1000 (but greater than or equal to 100), add “0” as a prefix.
  5. If the value is greater than or equal to 1000, do not add anything.

The goal is to get a 4-digit format for each value (examples: 0001, 0099, 0123, 1000).

Do you have any suggestions on the best way to achieve this in Dynamo?
Thanks in advance for your help!

As a new member, I can’t attach files here — but you can download the Revit file via this WeTransfer link: Unique Download Link | WeTransfer

Hi probably pad left could help

2 Likes