Collaborate forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Expression number decimals

KNA
Participant
Hello,

Is there a way to change the number of decimals in expression numbers? Although I adjust that there should be 1 decimal it always adds two (some kind of default setting). Changing the project settings won´t help.
?

thanks!
5 REPLIES 5

Hello KNA,

All is here : https://helpcenter.graphisoft.com/user-guide/84965/
Christophe - FRANCE
Archicad Designer and Teacher
Archicad 15 to 24 FRA FULL
OS 11 Big Sur

"Quality is never an accident; it's always the result of an intelligent effort " - John Ruskin

KNA
Participant
Hello,
Thanks for the reply. What I meant is that the program always add two decimals (see attachment) wheather I want the accuracy to be 0 or 1 decimals. Any idea how to change that so that it only shows the number of decimals that´s defined in the expression? The project settings won´t help..

KNA,

OK... 0 decimal deals with a "whole number" and if you want just one decimal you are able to edit your project preferences.
Christophe - FRANCE
Archicad Designer and Teacher
Archicad 15 to 24 FRA FULL
OS 11 Big Sur

"Quality is never an accident; it's always the result of an intelligent effort " - John Ruskin

KNA
Participant
Hello,

The project preferences has no effect on this - that´s the problem
So no matter what decimals I define in the settings it always gives two decimals.
I´m using a Finnish version of ArchiCAD.

Laszlo Nagy
Community Admin
Community Admin
The main problem here is that Preferences control the decimals places values will be displayed to.
In case your Property's Data Type is "Length", the Project Preferences->Calculation Units->"Length Unit" field will define how many decimals will be displayed for it.
In case your Property's Data Type is "Number", the Project Preferences->Calculation Units->"Numbers without Units" field will define how many decimals will be displayed for it.

So, in order to be able to display a value to the decimals you specify, you have to become creative, and you have to engage in creating Expression-defined Properties. What you can do is you can convert the "3D Length" parameter to a string and specify the number of decimals there.
The "STR" function makes it possible to convert a numeric value to string and at the same time, specify the number of decimal places for it. However, the "STR" function works only on Properties with "Number", "Integer", and "True/False" Data Types.
So, how do we convert a "Length" Data Type to a "Number" Data Type? This is possible by first using the STRCALCUNIT function to convert the "Length" Data Type to a "String" Data Type, then use the STRTONUM function to convert the "String" Data Type to a "Number" Data Type.
Then, we can use the "STR" function to convert that to a string, and we can also use another Property with the "Integer" Data Type to specify the number of decimals for the string.

So, how does all this look in practice?
I have created the following schedule that lists various Expression-defined Properties.
In the first Column, after the name of each Property, I wrote the Data Type of the Property for better understanding.


The Project Preferences->Calculation Units->"Length Unit" field is set to "4" in my file.
The Project Preferences->Calculation Units->"Numbers without Units" field is set to "2".

The third row of values displays the "3D Length" general parameter, which has a "Length" Data Type, and which displays the 3D length of the Wall's Reference Line. As you can see, values are displayed to 4 decimal places because the "Length Unit" field is set to "4" in the Project Preferences.

The fourth row displays the values of the "WallLengthSTR" Property with a "String" Data Type. It is an Expression-defined Property, which simply converts the "3D Length" Property to a String. It has the following code:
STRCALCUNIT ( {Property:General Parameters/3D Length} )
Although its displayed value looks like a Number, it is actually a String.

The fifth row displays the values of the "WallLengthNUM" Property with a "Number" Data Type. It is an Expression-defined Property, which simply converts the "WallLengthSTR" Property from a String to a Number. It has the following code:
STRTONUM ( {Property:CALC/WallLengthSTR} )
As you can see, values are displayed to 2 decimal places because the "Numbers without Units" field is set to "2" in the Project Preferences.

The sixth row displays the value of the "DecimalPlacesINT" Property with the "Integer" Data Type. This is not an Expression-defined Property, but a Property which can be set individually for each Wall element, and it will define how many decimal places our "3D Length" Property should be displayed to. As you can see, I set values between 0 and 4 for the 5 Wall elements shown in the schedule so we can see its effect.

The seventh row displays the values of the "WallLengthNUMTOSTR" Property with the "String" Data Type. This is the Property that will actually display the value we are looking for. It is an Expression-defined Property, which converts the "WallLengthNUM" Property from a Number to a String, and also uses the value of the "DecimalPlacesINT" Property to specify the number of decimal places. It has the following code:
STR ( {Property:CALC/WallLengthNUM}, {Property:CALC/DecimalPlacesINT} )
As you can see, the Property displays the value of the "3D length" Property with the number of decimal places we specified in the "DecimalPlacesINT" Property. So this is the result we were aiming for.

The eighth row displays the values of the "WallLengthNUMTOSTR2" Property with the "String" Data Type. It has practically the same expression as the previous Property, with the difference that it calculates the value in a single step. It has the following code:
STR ( STRTONUM ( STRCALCUNIT ( {Property:CALC/WallLength} ) ), {Property:CALC/DecimalPlacesINT} )
The advantage of this Property expression is that you will not need to create the "WallLengthSTR" and "WallLengthNUM" Properties to store intermediate results.
Actually, the reason I used those is to demonstrate the effect of Project Preferences settings on Length and Number type of Properties.


So this is how it can be achieved.
There is one disadvantage of this method: since the results displayed are not Numbers, but Strings, the Schedule will not be able to generate Total values for it.

Two more comments:
- This example shows how it is done for Length type parameters, but the same can be done with Area or Volume type parameters as well.
- Since these are Properties, their values can be used not only in Schedules but Labels as well.

I have attached a ZIP file, which contains the 5 Properties I have created for this little exercise. You can import the XML file into the Property Manager in AC24 or you can recreate the Properties from the above description in earlier versions. Make sure that all 5 Properties are made available for the Classifications you want to use them with.
....................................................................................................
Laszlo Nagy, Lead Moderator, Community Admin
Get Archicad Tips at https://twitter.com/laszlonagy
AMD Ryzen 1700X CPU, 48 GB RAM, NVidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), WIN10 PRO ENG, AC20-AC25
Loving Archicad since 1995

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!