Custom Component Scripting
To be able to use the new Custom Components feature in AC 10, make sure that you have the "Custom Components Macros" folder (with the subfolders "Collection Macros" and "Type Templates") loaded for your working file.
When you create a new Custom Component from the menu File / Libraries and Objects / Save Custom Component, then the list of the possible custom component types you get there corresponds with the Type Template files that can be found in the Type Templates folder. (You can select component type if you had already drawn and selected a 2D/3D design of the custom component.) Moreover, each Type Template has a corresponding Collection Macro, too.
Collection Macros are used for scripting the custom component feature in the library parts. So if you want to include the feature of e. g. custom door leafs for your doors, you can use the already existing Door_Panel_Collection.gsm for that purpose. IMPORTANT: for example if you want to create door panels separately for e. g. internal doors and sliding doors, then you will have to use one Type Template/Collection Macro for the internal doors and another for the sliding doors, otherwise you'll get the same value list of panels in both door types' library parts. About the creation of new Type Template/Collection Macro gsm files see later (under "2. Creating new Type Templates and Collection Macros ").
1. Custom Component scripting with the existing Type Templates
1.1 Create a new parameter for selecting the Custom Component you want to use. As it can be seen on the door D1.gsm, gs_cust_panel is available when Door Panel Style = Custom Panel, otherwise it is hidden/locked.
1.2 In the Master Script an array type variable must be initialised. This will contain
the names of the custom components that will be created by the user. As the
variable can have an indefinite number of values, use the "
command to initialise it.
1.3 In the Parameter Script the value list of the custom component names must be
created. Therefore first you must call the Collection macro, and by the
returned_parameters" command you'll get the component names for the
value list. Then by the "
values" command you create the value list
for the Custom Panel Name parameter. See screenshot here below.
1.4 Before the next step you have to decide about the custom component’s type. Its size can be fix (in this case it will appear in the library part with the same sizes as the user draws it on the floor plan, e.g. taps, handles, knobs…etc) or altering (its size will be defined by the corresponding parameter of the library part which includes it, e.g. door panels, window sashes, sinks…etc)
Note: the collection macro’s scripts depend on the custom object’s type too (see later in 2.4)
1.41 Altering size: in the 3D Script of the doors (or in the corresponding door panel macro) you must call the Collection macro with the correct A/B/leaf thickness dimensions. Plus, you must give the "gs_ptype" variable the value of your custom component parameter (in this case: gs_ptype=gs_cust_panel, which means the name of the custom door leaf). Before the macro call you may make some transformations, as the origin of the custom component (in this case the custom door panels that will be created by the user) is the left bottom corner. Note: in case of custom 2D symbols the 2D script must be used for the collection macro call.
1.42 Fix size: like above, but you don’t give the library parts' values of A, B, ZZYZX ( width, depth, height) for the collection macro.
2. Creating new Type Templates and Collection Macros
2.1 First create a new library part from the menu File / Libraries and Objects / New Object. This library part must be a Template, and NOT Placable. In the Select Subtype option choose Custom Component Template.
2.2 You can create the same way a new Collection Macro as well, in this case in the Subtype Hierarchy you must select Custom Comp Collections.
While the Select Subtype dialog is open, you can see the GUID of the object at the bottom. Click on the name of the newly created Collection macro and copy the entire GUID code.
2.3 Open the Type Template file that you have just created. Here you have two parameters by default: "GUID of matching collection macro" and "F. name of matching collection macro". Paste the GUID that you copied from the collection macro to the first, and type in the name of the collection macro to the second.
2.4 In this step you have to decide again that you would like to use a fix size or an altering size custom object in the library part.
Independently of this type you have to make these scriptings in the collection macro:
add to Master Script these two rows:
dim pt pt= ""
end pt" to the Parameter Script.
Explanation: if you draw a Custom Component, then select a Type Template for it and save, the Custom Component Add-on gives to the corresponding Collection Macro’s “pt” array values the names of custom components which are saved by this template. The placeable library part (door, window, sink etc) receives this array and makes a value list for the corresponding parameters, and the user can choose between them. Of course the selected component has to call in the objects’ 2D and/or 3D script too, it happens via the Collection Macro.
2.41. Now if you would like to call an altering size custom object you have to leave empty the 2D and 3D scripts and the Custom Component Add-on will generate automatic calls of the custom objects( please notice that it gives the placeable object’s width, depth and height to the custom object)
The Add-on will generate in the 2D and 3D scripts like this:
2.42 If you would like a fix size custom object you have to write a special comment in 2D and 3D scripts. Between a "[MACRO_CALL"] and another ["MACRO_CALL]" tag you can write an arbitrary GDL script and the Add-on will generate the custom object callings using this special commented script. In this script you have to call “xxx” and the Add-on will replace the xxx with the custom objects’ name.
E.g if you write this in the 2D and 3D scripts:
the Add-on will generate the callings of custom objects like this:
Please notice that in this case the custom objects will be called with their original sizes.
By this the new Type Template and Collection Macro are created, you can use them in the same way as it is explained here above (under "1. Custom Component scripting with the existing Type Templates").