How to use Custom Components in your library?

Example objects for this post can be downloaded here.

There are some situations when you would like to add some custom components to your libparts. In these cases you can create your own custom components, besides of using the ones from ARCHICAD Library.

Why is it better to create your own custom components?

  • your lcf library can be independent from the official libraries
  • you won’t need to change your libparts if ARCHICAD’s custom libparts change
  • ability to upload to BIMcomponents

Creating a custom component

1. Create your Custom Component Template and Custom Component Collection elements.

The easiest way in ARCHICAD is to open existing elements, and save them with “Save as…” into your custom library folder.
The example was created using the “Custom Knob” as a template file and “Knob_collection” as a Collection element.
To open them, get the Window/Toolbars/Edit GDL Library Parts toolbar, and use “Open object by Subtype…” menu:
Browse the subtype tree and open the above 2 objects:

Save them with custom names into your library folder, then load the folder into ARCHICAD.

2. Change the data stored in the template file

Change these 3 lines of the parameter script using the current data from your library (Custom Table Leg.gsm in example):

parameters coll_name= "Knob_Collection.gsm"
parameters coll_guid= "{792251AA-3310-4E1F-B787-19075AC87358}-{8442B5FB-C37F-4AA8-98CC-E05E544ABD8A}"
parameters ac_custom_component_type_name = `Knob`

Line 1: collection file’s name. Change it to the name of your own object (“TableLegCollection.gsm” in example).
Line 2: collection file’s ID. Change it to your collection file’s ID, which can be reached in the open object by subtype dialog.
Line 3: display name of the custom component for the “Save as” menu. Change it to your liking.
In the example it looks like this:

parameters coll_name= "TableLegCollection.gsm"
parameters coll_guid= "{4DE3723B-AE55-9445-B3FB-E4AFD781F915}-{2DFB201A-5FDB-BE7B-662E-B708C2824325}"
parameters ac_custom_component_type_name = `Table Leg`

Check that the information changes in the template libpart’s parameter list, too.

3. Add new parameters to your library part

Open the library part you want to associate custom parts with.
A String type parameter is needed to store the custom library part’s name (“customLegName”). In the example, there is also a Boolean type parameter in the libpart to enable/disable custom solution (“bCustomLeg”).

4. Parameter script modifications

Get the available custom components list to make a value list, and lock/hide the parameter when no custom part needed:

if bCustomLeg then    ! if the custom Boolean is ON
	dim gs_pt[] ! create an empty array
	call "TableLegCollection" parameters returned_parameters gs_pt   ! load the available custom component names into the previously defined array
	values "customLegName" gs_pt ! use the given array as value list
	lock "customLegName"
	hideparameter "customLegName"

5. Call the collection macro from your 3D script

If the custom mode is selected and there is at least one available custom component, then call the components macro. You can define the A-B-ZZYZX sizes and you need to pass the custom component’s name. The user defined custom element will be distorted to fit exactly in the defined A-B-ZZYZX size box.

if bCustomLeg and customLegName <> "" then
	call "TableLegCollection" parameters	A		= 0.1,
						B		= 0.1,
						Zzyzx		= legHeight,
						gs_ptype	= customLegName
	cylind legHeight, 0.02

6. Create an lcf, and test it

Your lcf file should contain your custom component template and collection file and the library parts using it. Load your lcf to a new plan, make a few custom components in the plan, and test your library with them.