BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

GDL
About building parametric objects with GDL.
SOLVED!

Format numbers with leading zeros ?

Nader Belal
Mentor
Hi everyone,

Here is a simple question, how to convert integer numbers to strings with leading zeros using str or str{2} functions ?

ex:
1 to be show as 01 or 001
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Laszlo Nagy
Community Admin
Community Admin
After you converted it, you should inquire the length of the string (which will be 1, 2, or 3), and depending on that value, fill the beginning of the string with leading "0" characters.
Loving Archicad since 1995 - Find Archicad Tips at x.com/laszlonagy
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac27

View solution in original post

3 REPLIES 3
Karl Ottenstein
Moderator
If the format string for the STR function was like normal programming languages, this would be easy, but alas it is 'unique' and seems to have no way of producing leading zeros.
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Solution
Laszlo Nagy
Community Admin
Community Admin
After you converted it, you should inquire the length of the string (which will be 1, 2, or 3), and depending on that value, fill the beginning of the string with leading "0" characters.
Loving Archicad since 1995 - Find Archicad Tips at x.com/laszlonagy
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac27
Nader Belal
Mentor
Thank you all
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
Learn and get certified!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!