BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

REF COMPONENT Property Script

Anonymous
Not applicable
I have built a part that comprises of several beam sizes. I am trying to write another script that references a component that I created in the database library. The name of the component is "4x6x8 Spruce Beam" The Key Code is "80000" and the component code is "X31040608" I already have the value that I want to multiply by so I don't need to add it to the script. According to the Archicad help this is what it looks like:

"REF COMPONENT code [, keycode [,
numeric_expression]]

Reference by code and keycode string to a component in an external database. The value to multiply by in the component database can be overwritten by the optional numeric expression specified here"


I have tried several different combinations with my numbers to get this script to work and can not figure out what I am doing wrong. See Below:

IF beam_size='4x6' THEN
IF a<8.00 THEN
REF COMPONENT X31040608 , 80000
ENDIF

Everytime I run a check script I get an error, the one above requests a string type expression.

Any help would be greatly appreciated. Thanks.

Barry Halloran
12 REPLIES 12
Anonymous
Not applicable
Hello

Can you try this syntax :
REF COMPONENT X31040608 [, 80000 [, 1]]
Anonymous
Not applicable
FMR,

I tried that before and it returns a Non-Declared index variable error. Thanks.

Barry
Anonymous
Not applicable
I never work with components, but I think that the syntax is good but you need to declare your component somewhere.
The GDL Documentation is not completely clear on this point. May be you should create and declare a Database set where are your components.

Some "Master GDL scripter" can certainly help you more…
Anonymous
Not applicable
Thanks for your help.

Barry
Karl Ottenstein
Moderator
Barry wrote:
REF COMPONENT X31040608 , 80000
Hi Barry,

We're back to basic GDL syntax here: X31040608 looks like a variable to GDL, and as an uninitialized variable, its value is zero (0).

If these values are constants, as in your example, they must be in quotes since they are arbitrary text. (Of course, if the code was inside a string parameter or variable, such as strCode, then of course strCode would not be in quotes ... because you want the value of that variable.)

The following example works:
DATABASE_SET "AC_9_US"
REF COMPONENT "031-00000", "CSI.11"
But, note that "in real life" the DATABASE_SET command belongs in a MASTER_GDL script so that it is only executed once, unless you are pulling things from multiple databases.

HTH,
Karl

PS The above is just for illustration purposes and assumes some logic around the REF COMPONENT, as in Barry's example. If you just want to retrieve a component inside of an object, then use the user-friendly Components section of the GDL editor.

Create a New entry, then use Link to Database Item to create a hard-coded link, like the first line int the screenshot. All fields are locked, and match the database exactly. If you create a new entry and do not link, then you have pop-up menus to choose the database, key, and enter a new or existing code and text, etc. Probably not the greatest idea to do both since you could easily create conflicts with existing codes and names.
components.gif
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Karl Ottenstein
Moderator
Another P.S.

Barry,

I think you may end up looking at a huge number of IF/THEN statements to select your components if you have very many beam sizes and length combinations. You may find that it is easier to use the various GDL string manipulation functions to "build" the database code from the input parameters, if you encode your beam information into the codes.

Karl
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
Karl,

Thanks again for your knowledge. I will give it a shot and let you know the results. I am also taking your advice and looking into some GDL classes.

Barry
Anonymous
Not applicable
Karl,

That worked. My only problem now is similar to what I had before. I can't figure out why whenever I add a < statement the script fails. For example if the length of the beam:

IF beam_size="4x6" THEN
IF A<8'-0" THEN
REF COMPONENT "X31040608" , "80000"
ENDIF

The script works perfect without the nested IF statement. I must be missing something. Thanks for your help.

Barry
Karl Ottenstein
Moderator
You need another ENDIF, Barry, or you need to move the REF statement onto the same line as your previous IF.

Refer to the GDL manual for the syntax. You can only omit the ENDIF for an IF that has a single statement immediately after the THEN (and thus also has no ELSE clause).

IF expression THEN statement

or

IF expression THEN
group of statements
[optional: ELSE / group of statements]
ENDIF

The key bit that I suppose was not obvious when you looked at the manual is that line breaks are often significant, as in this case.

Karl
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Learn and get certified!