We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Documentation
About Archicad's documenting tools, views, model filtering, layouts, publishing, etc.

Expression to convert Story Number to Letter

jimmynimmy
Contributor

Hi,

 

I am dabbling in Expressions. I'd like to convert the Story Number to a Letter for some storeys, and others to remain unchanged i.e.

 

Story Number 0 converts to B2

Story Number 1 converts to B1

Story Number 2 converts to G

Story Number 3 (and above) unchanged.

 

I have worked out how to change 0, 1, and 2 to B2, B1, and G, but can't work out how to return the Story Numbers above this as unchanged. When I evaluate something on Story Number 4, "Evaluate..." returns <Undefined>.

 

This is the expression : 

IFS (

CONTAINS ( "1", STR ( {Property:General Parameters/Home Story Number} ) ), "B2",

CONTAINS ( "2", STR ( {Property:General Parameters/Home Story Number} ) ), "B1",

CONTAINS ( "3", STR ( {Property:General Parameters/Home Story Number} ) ), "G" )

 

Any ideas?

 

Thankyou 🙂

 

Operating system used: Windows

9 REPLIES 9
Barry Kelly
Moderator

Can't you just give the storeys a name and use that?

Or do you need a different name for other purposes?

 

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

Hi Barry,

 

We give the storeys intuitive names like Ground, Level 1, Level 2, Roof

 

To create unique codes for Doors + Windows in Apartment / Room Modules we include the Story Number in the Label. Using the storey name would be too long... a short code is needed. These codes becomes a bit confusing when the tag displays 0 for Ground, -1 for B1 or -2 for B2 for example - so trying to do above conversion.

 

As well, sometimes our Story Numbers don't relate i.e. Level 7 may be on Story Number 5 - we use some arithmetic operators in the Expression so the code in the door relates to the storey it is on...

 

What are your thoughts?

If you are not using the intuitive names for anything, I would just change them to G, B1, etc.

 

Otherwise in your expression, you would have to convert all of the other storey numbers to text as well, 4 = "4" , 5 = "5".

i.e. continue your IFS statement ... CONTAINS ( "4", STR ( {Property:General Parameters/Home Story Number} ) ), "4" 

This will only work in this case up to 9 storeys.

Storey 10 will also be evaluated as "B2" because it contains "0".

 

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

We typically name views by the Project Map, so these names become visible in Titles and is clearer as full name..

 

Hmm OK - was hoping that was not the case.

 

There is no way to do something like... apply this expression for B1, B2, G but for all others just print the Home Story Number? Can the Sequence function be used in any way?

 

Thanks for the response


@jimmynimmy wrote:

There is no way to do something like... apply this expression for B1, B2, G but for all others just print the Home Story Number? Can the Sequence function be used in any way?


Not really.

You are creating a 'string' property for storeys 0, 1 & 2 (B1, B2 & G).

So you will need to also convert all the other storeys to also have the same string property equivalent.

Even though it will look like a number, it will be a 'string' (text version) of that number.

You will need to do the conversion for each storey.

 

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
Xandros
Advisor

Hi

you could try the following addition to your expression to achieve a result.
But have a look at the screenshot below for the outcome and change your expression accordingly:

 

IFS (
CONTAINS ( "1", STR ( {Property:General Parameters/Home Story Number} ) ), "B2",
CONTAINS ( "2", STR ( {Property:General Parameters/Home Story Number} ) ), "B1",
CONTAINS ( "3", STR ( {Property:General Parameters/Home Story Number} ) ), "G",
TRUE, STR ( {Property:General Parameters/Home Story Number}, 0 ) )

 

 

Xandros_0-1712222690307.png

 

ArchiCAD 27 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti
Yves
Advocate

Hi,
Here is another formula possibility using the floor number directly

Sorry formula in French

IFS ( {Property:Paramètres généraux/Numéro d'étage d'implantation} = 0; "B2"; {Property:Paramètres généraux/Numéro d'étage d'implantation} = 1; "B1"; {Property:Paramètres généraux/Numéro d'étage d'implantation} = 2; "G"; OR ( {Property:Paramètres généraux/Numéro d'étage d'implantation} < 0; {Property:Paramètres généraux/Numéro d'étage d'implantation} > 2 ); STR ( {Property:Paramètres généraux/Numéro d'étage d'implantation}; 0 ) )

 

Yves Houssier
Belgium
Archicad 19 -> 24
iMac - Mac Os 10,13

Thanks everyone..

I ended up doing below, where Storey 3 here is Ground :

CONCAT ( IFS ( {Property:General Parameters/Home Story Number} = 3, "G", AND ( 3 < {Property:General Parameters/Home Story Number}, {Property:General Parameters/Home Story Number} < 13 ), CONCAT ( "L0", LEFT ( RIGHT ( STR ( {Property:General Parameters/Home Story Number} - 3 ), 4 ), 1 ) ), {Property:General Parameters/Home Story Number} >= 13, CONCAT ( "L", STR ( {Property:General Parameters/Home Story Number} - 3, 0 ) ), {Property:General Parameters/Home Story Number} < 3, CONCAT ( "B0", LEFT ( RIGHT ( STR ( {Property:General Parameters/Home Story Number} - 3 ), 4 ), 1 ) ) ) )

 

This works more generally, so anything above Storey 3 will include an L infront. Storey 3 will be called G. And anything below will include a B infront (but only works to B09)

@Xandros How did you create that table?

 

  1. I created an empty file with a few storeys (-12 to 13)
  2. added the expression as a property available to every classification
  3. placed an element (wall for example) on each storey
  4. created an interactive schedule 
    • criteria set to fit those placed elements
    • fields are HomeStoreyNumber and the property containing the expression
  5. if number of elements per storey is bigger than 1 (for example if this schedule is created in an already existing project), use the option to merge the scheduled items
ArchiCAD 27 GER / Win10
Intel i9-9900K / 64GB RAM / nVidia GeForce RTX 2080 Ti

Setup info provided by author