Need help with an Expression

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-02-07
10:56 PM
- last edited on
2025-01-30
11:19 AM
by
Aruzhan Ilaikova
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:
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".
you can see how it's currently working for the top and bottom objects but not the middle one that ends in 1/4"
Archicad 24 - Latest Build
Archicad 25 - Latest Build
- Labels:
-
Classifications & Properties

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-02-08 12:06 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-02-08 01:51 AM
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).
Barry.
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2022-02-11 01:35 PM - edited 2022-02-11 01:37 PM
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.
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac28