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
Id like to help if i knew what cmu are.

also, if its only a 2D object, do you have to worry so much about things which rise vertically, if they are above each other, you may only have to script for one of them in the 2D.

Michele wrote:
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.
Anonymous
Not applicable
Cmu are concrete masonry units - Concrete block. I want the user to be able to say I want 14 cmu (stacked vertically - like if you have a concrete block foundation wall and you cut a section thru it. )I want to show the section view of the concrete block. The fill that is used in archicad doesn't work for us. We need more detail in the sections so instead of drawing lines and arcs to embellish the sections I thought I could make a object that would be able to show me what I want to see. I thought I could make the object be parametric so that if I needed 14 courses of 8" cmu that it would automatically draw the correct thing 14 times. I've made one cmu as an object but I want to add parameters to be able to add courses. IF cmu_no = 2 THEN GOSUB 200. But I want the GOSUB to look up the sub routine 100 and then move up 8" in the y direction then add another 100. 100 being the shape of 1 cmu + 1 mortar joint (to get specific). How do I write that as code.
Thanks,
Michele
!cmu_ht is the height of your block.

FOR k=1 TO cmu_no 
    ADD2 0, cmu_ht*(k-1) 
    GOSUB 100 !draw cmu 
    DEL 1 
NEXT k
James Murray

Archicad 27 • Rill Architects • macOS • OnLand.info
The object would be better if you gave the height and let it figure out how many blocks to draw.

Instead of having the user count the blocks,

!B=height of stack

cmu_no=INT(B/cmu_ht) !number of whole blocks
HOTSPOT2 0,0
HOTSPOT2 0,B !stretchiness
FOR k=1 TO...
To get really useful you could have it fill in a partial block at the top:

part_cmu=B-(cmu_no*cmu_ht) !remainder
FILL 'cmu_fill' !whatever it is
ADD2 0, cmu_no*cmu_ht !go to top of top block
POLY2 4, 3, (points describing a rectangle where height=part_cmu and width=cmu_width) 
DEL 1
James Murray

Archicad 27 • Rill Architects • macOS • OnLand.info
David Larrew
Booster
Or you could try:
http://www.objectsonline.com/arc/default.tpl?cid=38398&pid=A01764
Also found here:
http://www.archisolutions.com/Store/GDL.htm

The upgraded version found at the latter link allows the user to construct the detail by course number or height/length. (Of course the older version can also be upgraded.)
David Larrew, AIA, GDLA, GSRC

Architectural Technology Specialist

a r c h i S O L U T I O N S



WIN7-10/ OSX 10.15.7

AC 5.1-25 USA
tsturm
Newcomer
Perhaps David is correct in suggesting that you just purchase the part on Objects Online and be done with it. Help David along.

But how about a suggestion to help those who what to create parts on their own.

Our office made just such a part. James has a good start on the method to make the object be stretchy. There also are many other ways to make the part to get around other problems which will occur when making the part stretchy unless you know where they are. The easy way out is to make the part read a parameter that the user inputs. This number of courses will tell the control loop to send the object created in the subroutine along that number of times. Great way. Simple. Time consuming when grabbing the part from some other sheet and wanting to make more or less courses. As you have to open and type a new number every time you want more or less courses. Of course a crafty person could use the Object ID box to enter new numbers on the fly. This ID box is at the very bottom of the Info strip. Here you can adjust a single parameter without ever opening the Settings Box. Very useful for Door, window or room numbers as well.

But we are talking about a CMU coursing symbol. James is right about using the INT (B/CMU_size) to get the number of courses and the number of times the loop which will call the subroutine for the CMU block. He also has the right idea of using hotspot2 0,0 and hotspot2 0,B. I would add the two other hotspot corners as Hotspot2 A, 0 and Hotspot2 A,B. But where the object will get hung up and no longer be stretchy is when hotspots are no longer on the outer corners of the CMU symbol. It would be best to use the FRA command to create a part (last CMU unit) to fill the remaining distance. The FRA command returns the decimal value of the remainder used in the INT command earlier (B/CMU_size). Written as FRA (B/CMU_size). You cannot simply apply this value to a drawn 2D part as the last distance to go but you can then redefine the height of the CMU block if you are using a subroutine to define the object's shape.

If like our office, you chose to blast out twelve different CMU and brick symbols in thirty minutes, because GS could not include them in the AC library, as drawn 2D symbols and called them in the 2D script using the FRAGMENT2 x, 1 command then used the INT and FRA commands to run the number of courses you would need to use the MUL2 command on the last CMU unit to get it to fit (squish) the remaining distance assuming the "B" distance is not equal to the number of courses. Key thing to note here is distort only the CMU and not the mortar of the last course. If your 2D symbol is both CMU and mortar then the last course will have distorted mortar. Only distort the CMU. So when you apply the MUL2 command to the CMU unit remember to subtract the mortar height from the remaining distance. This remaining distance is the value from the FRA command. This might be--

RMG_distance=FRA (B/CMU_size)
MUL2 1, RMG_distance-3/8" ! 3/8" is mortar height

Distorting the last CMU block may seem very odd, but not when it makes the stretchyness of the object complete and the bounding hotspots have a spot to be found by the user later.

About making the last unit fill in as part of the symbol, my opinion is this makes the script complicated and opens the chance for a total loss of the drawing when the part is changed later or lost. I would recommend using separate parts for bond blocks, Lintels, reinforcing and horizontal reinforcing. Though these could be added to a part which is used to make CMU walls. Losing the part means a loss of the drawing. Lossing just one part of twelve is easier to recoup then one which does the work of twelve. Just a recommendation.

Also though the desire may be there to make the 2D symbol scripted versus drawn, lots of time is used to create this scripted object. The most important thing for our office is get the parts done easily and with options to complicate it later. For this object, the script is the most valuable part as the successful creation was used to create twelve other symbols which used the same process but different 2D images. The 2D scripted images would have taken a junior AC user lots of time to figure out. Our symbol script was worked out by someone with some experienced skill at GDL then handed to a beginner to continue developing the other symbols/parts. This gets the experienced person on to other tasks and beginner more confidence in using GDL and making symbols/parts.

HTH
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
Thanks for all your great ideas. I'm off work today but will try these once I get back to the office. I think I do want to make it stretchy with putting in as many whole blocks as it can.

Thanks again,
Michele
Anonymous
Not applicable
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
Anonymous
Not applicable
Michele,

Try it like this:

unit_ht = 8"
no_cmu = INT(b/unit_ht)


It is better to initialize variables before the actual working part of the script. This is typically done in the master script so the values can be used in 2D, 3D, etc. This also applies to repeated constant values (like "unit_ht"). Your scripts will be much more maintainable this way.

Hotspot2 0, 0
Hotspot2 0, b


These will allow you to stretch the blocks vertically and keep the stretch constrained in that direction, assuming you don't add "Hotspot2 a, n" (where "n" is any value)

FOR i=1 TO no_cmu ! STEP 1 is the default
GOSUB 100
ADD2 0, unit_ht
NEXT i


You don't need the STEP value unless you want to increment by an amount other than 1.0. I have changed the stepping variable to "i" which is the traditional standard. I usually use "j" and "k" for nested FOR/NEXT loops.

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


I hope this is clear.