Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Using FRA to create striped cladding

derekjackson
Expert
Hi,
I'm trying to create an object which allows for striped panels of cladding.

The user picks 3 materials and these need to be used on every third iteration to draw a striped object.

The code I have increments a counter 'count' in a loop, shortly before these lines:
	IF (FRA(count/3)) = 0 THEN MATERIAL mat_board
		IF (FRA(count/3)) = 1/3 THEN MATERIAL mat_board2
		IF (FRA(count/3)) = 2/3 THEN MATERIAL mat_board3
Unfortunately, it only seems to alternate the first 3, then it seems to get stuck on mat_board for all iterations afterwards.

Any ideas?
http://www.lsiarchitects.co.uk
http://derekjackson.artstation.com
AC19 / 21 / 23 / 27
Windows 7 Intel Xeon 18Gb
4 REPLIES 4
Anonymous
Not applicable
Hi,

try it:

eps=0.001
IF ABS((FRA(count/3)) - 0 )<eps THEN MATERIAL mat_board
IF ABS((FRA(count/3)) - 1/3 )<eps THEN MATERIAL mat_board2
IF ABS((FRA(count/3)) - 2/3 )<eps THEN MATERIAL mat_board3

cheers,
derekjackson
Expert
Perfect, thanks!
http://www.lsiarchitects.co.uk
http://derekjackson.artstation.com
AC19 / 21 / 23 / 27
Windows 7 Intel Xeon 18Gb
Karl Ottenstein
Moderator Emeritus
Since count is an integer and never has fractional values, you shouldn't really be using floating point arithmetic anyway.

The simplest method is to use the MOD (modulo) operator.

(count MOD 3) will always equal exactly 0, 1 or 2

and gives you much simpler code (within what GDL offers):
nStripe = count MOD 3
IF nStripe = 0 THEN MATERIAL mat_board
if nStripe = 1 THEN MATERIAL mat_board2
if nStripe = 2 THEN MATERIAL mat_board3
Of course, if you have an array set up, then you can just replace all of the above with:
MATERIAL mat_board[(count MOD 3)+1]
where the +1 is necessary since GDL array indices begin at 1. An advantage of the array is that you can generalize your script to handle any number of stripes, defined parametrically. The other solutions are 'hard coded' to a specific number of stripes.

Cheers,
Karl
AC 28 USA and earlier   •   macOS Sequoia 15.3.1, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
derekjackson
Expert
Superb, far easier. Thanks!
http://www.lsiarchitects.co.uk
http://derekjackson.artstation.com
AC19 / 21 / 23 / 27
Windows 7 Intel Xeon 18Gb