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

help with code

Anonymous
Not applicable
I want to make a 2d object (to be used in sections) that can have x number of cmu high. I have the sub routine for the cmu shape for the 1 cmu. How do I write a code to say look at cmu_no and if cmu_no (cmu number) is 4 then take sub routine 100 and copy it up 3 times at x distance? I have the gdl cookbook if anyone wanted to point me to a section in there.

Thanks so much,
Michele
15 REPLIES 15
Anonymous
Not applicable
Thanks Matthew,
The code you gave me makes things a lot easier. Thanks for explaining it.

Michele
tsturm
Newcomer
Dear Matt

Can you provide some information on this MOD command as GS did not mention it in their Manual other than in the index.
Terrence Sturm, Architect
_______________
MBP OSX 10.15.4 Quad Core Intel i7 2.2hz
AC 17 build 5019
AC 22 build 7000
AC 23 build
AC 24 build 5000
Anonymous
Not applicable
The MOD (short for modulus I think) is the remaining part after subtracting the most integral wholes possible. For example:

INT(13/4) = 3

This is the integral number of 4's in 13.

13 MOD 4 = 1

This is the remaining value after subtracting those three 4's (12) from 13.

BTW: The function (in GDL) can also be expressed as 13 % 4.
Greg A_ Blunier
Contributor
The ADD2 command needs to include k as a multiplier or all the bricks get drawn on top of each other.
Michele wrote:
Is this how this code reads? I thought I understood the FOR NEXT loopp but I guess I don't.

GOSUB 100 !draw the first cmu block
FOR k=0 TO A STEP no_cmu !now copy the next lines and keep
! doing until you reach the no_cmu number
ADD2 0,8" !go up 8" in the y direction
GOSUB 100 !draw one cmu here
DEL 1 !start at beginning position
NEXT k !Start again at the ' FOR k=0 TO A Step ...' line
END:

100: !draws the cmu block


When I do this I only get 2 cmu blocks, even if no_cmu = 6
THanks,
Michele
ArchiCAD 22 USA Full and ArchiCAD 7

Windows 11
tsturm
Newcomer
So Matthew in your example along with the explanation of the MOD command lets take a nine foot high CMU wall.
Matthew wrote:

Try it like this:

unit_ht = 8"
no_cmu = INT(b/unit_ht)
FOR i=1 TO no_cmu ! STEP 1 is the default
GOSUB 100
ADD2 0, unit_ht
NEXT i

unit_ht = b MOD unit_ht
GOSUB 100


This will add a partial height (cut) block to the top of the stack to match the actual height you stretch it to.

END:
100: !draws the cmu block
This wall would be 13.5 courses high. According to the INT(b/unit_ht) equation with a result of 13.

So, if I understand your MOD command and the equation you gave. 8" goes into 9 feet 13 times with a remainder of half or 0.5. This now becomes your lenght for the last unit.
unit_ht = b MOD unit_ht
But this value is read as metric not imperial which was what the 8" was.

So did I miss something?

Why not use the FRA command to get the remainder?
Terrence Sturm, Architect
_______________
MBP OSX 10.15.4 Quad Core Intel i7 2.2hz
AC 17 build 5019
AC 22 build 7000
AC 23 build
AC 24 build 5000
Anonymous
Not applicable
Terence,

The MOD function is just the simplest approach. The FRA function works to produce a value of 0.5 in your example. This would then need to be multiplied by the unit height to produce the same value that the MOD function produces directly. Not really a big deal, it works either way.

Regarding the imperial/metric issue. The format for writing GDL in feet and inches really just serves as a function for conversion to the internal metric values. Typing 8" in GDL is really the same as typing 0.2032 (the equivalent in meters). The notations (even the metric ones) are just the surface display for us humans to understand. Internally everything gets converted to machine language that none of us would care to decipher.
tsturm wrote:
But this value is read as metric not imperial which was what the 8" was.

So did I miss something?

Why not use the FRA command to get the remainder?