topic Re: Expression number decimals in Collaborate forum
https://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223841#M28656
Hello KNA,<BR />
<BR />
All is here : <A href="https://helpcenter.graphisoft.com/user-guide/84965/" target="_blank">https://helpcenter.graphisoft.com/user-guide/84965/</A>Wed, 18 Nov 2020 18:59:27 GMTChristophe Fortineau2020-11-18T18:59:27ZExpression number decimals
https://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223840#M28655
<DIV class="actalk-migrated-content"><T>Hello,<BR />
<BR />
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.<BR />
?<BR />
<BR />
thanks!</T></DIV>Wed, 18 Nov 2020 15:39:01 GMThttps://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223840#M28655KNA2020-11-18T15:39:01ZRe: Expression number decimals
https://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223841#M28656
Hello KNA,<BR />
<BR />
All is here : <A href="https://helpcenter.graphisoft.com/user-guide/84965/" target="_blank">https://helpcenter.graphisoft.com/user-guide/84965/</A>Wed, 18 Nov 2020 18:59:27 GMThttps://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223841#M28656Christophe Fortineau2020-11-18T18:59:27ZRe: Expression number decimals
https://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223842#M28657
Hello,<BR />
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..Thu, 19 Nov 2020 12:00:26 GMThttps://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223842#M28657KNA2020-11-19T12:00:26ZRe: Expression number decimals
https://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223843#M28658
KNA,<BR />
<BR />
OK... 0 decimal deals with a "whole number" and if you want just one decimal you are able to edit your project preferences.Thu, 19 Nov 2020 12:57:32 GMThttps://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223843#M28658Christophe Fortineau2020-11-19T12:57:32ZRe: Expression number decimals
https://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223844#M28659
Hello,<BR />
<BR />
The project preferences has no effect on this - that´s the problem <IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_sad.gif" style="display : inline;" /> <BR />
So no matter what decimals I define in the settings it always gives two decimals.<BR />
I´m using a Finnish version of ArchiCAD.Tue, 24 Nov 2020 07:15:59 GMThttps://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223844#M28659KNA2020-11-24T07:15:59ZRe: Expression number decimals
https://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223845#M28660
The main problem here is that Preferences control the decimals places values will be displayed to.<BR />
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.<BR />
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.<BR />
<BR />
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. <BR />
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. <BR />
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.<BR />
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.<BR />
<BR />
So, how does all this look in practice?<BR />
I have created the following schedule that lists various Expression-defined Properties. <BR />
In the first Column, after the name of each Property, I wrote the Data Type of the Property for better understanding.<BR />
<BR />
<BR />
The Project Preferences->Calculation Units->"Length Unit" field is set to "4" in my file.<BR />
The Project Preferences->Calculation Units->"Numbers without Units" field is set to "2".<BR />
<BR />
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. <BR />
<BR />
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:
<PRE>STRCALCUNIT ( {Property:General Parameters/3D Length} )</PRE>
Although its displayed value looks like a Number, it is actually a String.<BR />
<BR />
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:
<PRE>STRTONUM ( {Property:CALC/WallLengthSTR} )</PRE>
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.<BR />
<BR />
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.<BR />
<BR />
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:
<PRE>STR ( {Property:CALC/WallLengthNUM}, {Property:CALC/DecimalPlacesINT} )</PRE>
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.<BR />
<BR />
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:
<PRE>STR ( STRTONUM ( STRCALCUNIT ( {Property:CALC/WallLength} ) ), {Property:CALC/DecimalPlacesINT} )</PRE>
The advantage of this Property expression is that you will not need to create the "WallLengthSTR" and "WallLengthNUM" Properties to store intermediate results.<BR />
Actually, the reason I used those is to demonstrate the effect of Project Preferences settings on Length and Number type of Properties.<BR />
<BR />
<BR />
So this is how it can be achieved.<BR />
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.<BR />
<BR />
Two more comments:<BR />
- 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.<BR />
- Since these are Properties, their values can be used not only in Schedules but Labels as well.<BR />
<BR />
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.Sun, 29 Nov 2020 10:37:47 GMThttps://community.graphisoft.com/t5/Collaborate-forum/Expression-number-decimals/m-p/223845#M28660Laszlo Nagy2020-11-29T10:37:47Z