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

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 26 USA and earlier   •   macOS 12.6.1, iMac Pro 10-Core, Radeon Pro Vega 64

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 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

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.

 

....................................................................................................
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-AC26
Loving Archicad since 1995

Start a new conversation!

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!