Collaboration with other software
About model and data exchange with 3rd party solutions: Revit, Solibri, dRofus, Bluebeam, structural analysis solutions, and IFC, BCF and DXF/DWG-based exchange, etc.

Need help with an Expression

mi_jan
Enthusiast
I’m trying to set up an expression to join properties “Lenght (a)” and “Width” of an object, but I can’t figure out how to get the rounding correctly. Any help would be greatly appreciated. 

What I want to do: Add an auto-text Label that returns the size of the OOTB wood stud object (DET_STUD 25) so that it shows 2x6, 2x8, 2x12 by picking up the “Lenght (a)” and “Width” and rounding them up. 

The Problem: It works great with any stud that ends in 1/2" actual size ( 2x2, 2x4, 2x6), but studs over 2x8 which the actual size ends in 1/4" get automatically rounded down instead of up. Archicad will return the “Lenght (a)” and “Width” properties as nominal size in the following format: #'-#" so the numbers are already rounded when they go into the expression. I have wasted more time than I want to admit trying to get this to work and I keep getting incorrect data type error messages. 

(See screenshots below)

The simple expression with which I started:
Stud Expression.png

 I have also tried replacing STRCALCUNIT( ) with STR( Width / 1 in) to no avail.


Below is where I see the expression heading;  I want to be able to show (2) 2x# when changing from Single to Double, 2 digits if stud Width is greater than 7", or 1 digit if stud width is Less than 7".

Stud Expression-multiple functions.png
 
Pink text is the expression inside of an auto-text label.
you can see how it's currently working for the top and bottom objects but not the middle one that ends in 1/4"

Example of autotext.png


Example of autotext.png

iMac - MacOs Big Sur 11.6.6
Archicad 24 - Latest Build
Archicad 25 - Latest Build
3 REPLIES 3
Karl Ottenstein
Moderator

As you noted, this is not an issue of rounding since there is no way to "round" 11 1/4" to be 12".  You are fighting with the north american nominal vs milled size of lumber which doesn't satisfy any mathematical formula.   You can either do a table lookup process... or as you suggest in one of your screenshots, do a 'hack' that recognizes that you have to handle lengths greater than 8 by doing something weird like adding ½" and then rounding the result.

 

One of the forum moderators
AC 28 USA and earlier   •   macOS Sonoma 14.7.1, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Barry Kelly
Moderator

Simple rounding will round up or down as required.

However look at the available functions and you will see there are special round up/down functions as well as ones that can round to a multiple (i.e. in metric system timber is ordered in lengths of 300mm).

 

BarryKelly_0-1644281474581.png

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Laszlo Nagy
Community Admin
Community Admin

In metric, you could just add 0.5 to the value and get the Integer part of it with the ROUNDDOWN operator.

So if the value is between 0.00 to 0.4999999, you add 0.5, it will be between 0.50 to 0.9999999, and so its integer will be 0.

If the value is between 0.50 to 0.9999999, you add 0.5, it will be between 1.00 to 1.4999999, and so its integer will be 1.

I guess this could be applied to imperial as well.

 

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