> ## Documentation Index
> Fetch the complete documentation index at: https://calcs.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Template Features

> Advanced features for Calcs.com templates including material changes, load combinations, and data linking

## Changing Material

Calcs.com offers users the ability to change from one material to another. [Public documentation available here](https://support.calcs.com/article/25-how-to-change-materials-for-example-swap-templates-between-timber-and-steel).

### Supported Widget Types

| Widget Type | Supported? | Comments         |
| ----------- | ---------- | ---------------- |
| input       | Yes        |                  |
| table       | Yes        | Same table shape |
| lookup      | No         |                  |

<Note>
  **FAQ:** Can you change between ASD & LRFD standards?
  **Answer:** Yes, however, lookups are not supported so the member selector will not be transferred.
</Note>

<Warning>
  Values are plainly copy-pasted from referenceId to matching referenceId with no consideration for widget units. If one widget asks for spacing in feet and the new material asks for spacing in inches, the new spacing will be off by a factor of 12.
</Warning>

## Load Combinations

### Philosophy

The way load combinations are implemented follows these principles:

* The set of load combinations used is the same for an entire project
* Load combinations can be set by users ONLY in Project Defaults, not overridden in individual sheets
* We provide common sets of load combinations with user selection, plus custom options
* All factoring of loads per load combinations happens in the solver
* Load factors are split between project and template levels:
  * *How to apply* factors is defined on the project level
  * *What values to apply* is defined on the template level

### Implementation Structure

Working from project level downwards:

#### Project Defaults

<Steps>
  <Step title="Hard-coding Load Types">
    **loadTypesBase2**: Currently hard-coded in Project Defaults

    **combConc2**: Load types that should always be combined (e.g., distributed and concentrated live loads in AU/NZ)
  </Step>

  <Step title="Setting Load Combinations and Factors">
    **LCs\_str\_type**: Sets both the load combinations and how to apply factors

    * `LCs_str2`: Load combinations passed to solver in every sheet
    * `LCFact_str2`: Mappings for applying load combination factors
  </Step>

  <Step title="Default Factor Values">
    **LCFact\_type**: Set of load combination factors (e.g., ψ factors in Eurocode)

    * Creates `LCFact_*` databases available to templates
  </Step>

  <Step title="Default Selections">
    Default category of imposed load - can be overridden in individual sheets
  </Step>
</Steps>

#### Template Level

Templates pass through or modify values from Project Defaults:

* **Passed unchanged**: `loadTypesBase2`, `combConc2`, `LCs_str2`, `LCFact_str2`
* **Potentially modified**: `LCFact_DB` - factor values can be overridden

### Load Combination Factors Structure

#### Factor Values: LCFact\_DB

```json theme={null}
{
  "S": [0, 0.7, 0.5, 0.3],  // Snow load factors
  "all_x": [0, 1.0, 0.9]     // Applied to all load types
}
```

<Note>
  The first item (index 0) is always ignored and set to 0. Think of index = 0 as meaning 'don't apply the factor'.
</Note>

#### Application Instructions: LCFact\_str

Array of length equal to number of load combinations:

```json theme={null}
{
  "S": [1, 0, 1, 1, 3, 0]  // Indices referring to LCFact_DB values
}
```

## Data Linking Between Templates

### Basic Load Linking

Load linking allows importing data from another calculation, commonly used for transferring beam reactions to column calculations.

#### Creating an Export

1. Create an equation widget with table format (`[[]]`)
2. Check the "Export" box
3. Set a unique `referenceId`

```json theme={null}
{
  "type": "computed",
  "result": "[[label, value1, value2]]",
  "export": true,
  "referenceId": "beamReactions"
}
```

#### Creating an Import

Create a table widget with matching columns and linkRow configuration:

```json theme={null}
{
  "type": "table",
  "linkRow": {
    "mappings": [
      {
        "sourceColumn": 0,
        "targetColumn": 0,
        "prependSheetName": true
      },
      {
        "sourceColumn": 1,
        "targetColumn": 1
      }
    ],
    "description": "Link to Beam Calculator",
    "referenceId": "beamReactions",
    "linkRequired": true,
    "sourceDataColumns": [
      {
        "label": "Label",
        "sorted": true
      }
    ]
  }
}
```

### Advanced Linking

<Accordion title="Advanced Linking Resources">
  [Video tutorial on backend implementation and design patterns](https://drive.google.com/file/d/1I0imRkK91oU96elaBzjVOr79XAieMuqR/view?usp=sharing)

  Key considerations:

  * Backend processing
  * Designing new link types (not necessarily loads)
  * Common pitfalls and solutions
</Accordion>

## Print/Export Rules

### Current Export Modes

<Tabs>
  <Tab title="Detail">
    * **Format**: Single column with references for equation widgets
    * **Widgets printed**: All widgets
    * **Order**: JSON file order
  </Tab>

  <Tab title="Standard">
    * **Format**: Single column
    * **Widgets printed**:
      * All input-related widgets
      * Images and diagrams
      * Tables with `showInSummary: true`
      * Equation widgets with `showInSummary: true` or checks
    * **Order**: JSON file order
  </Tab>

  <Tab title="Summary">
    * **Format**: Two columns, minimal details
    * **Widgets printed**: Only those with `showInSuperSummary: true`
    * **Order**: By page then column
  </Tab>
</Tabs>

## Widget References & Standards API

### Structured References Format

New `referencesJSON` field for direct linking to standards:

```json theme={null}
[
  {
    "id": "/api/standards/AISC/AS4100_2020_1/section/5.6.3",
    "name": "AS 4100:2020, Cl 5.6.3",
    "description": "Non-compact Sections"
  },
  {
    "id": "https://awc.org/publications/2018-nds-supplement/",
    "name": "NDS 2018 Supplement, Table 5B",
    "description": "Reference Design Values"
  }
]
```

### URL Structure for Standards API

Pattern: `/Authority/Standard/type/Type-reference/sub-type/Sub-type-reference`

Examples:

* `section/5-6-3` - Clause 5.6.3
* `table/5-6-3A` - Table 5.6.3(A)
* `equation/9-2-2-4` - Equation reference

## Markdown Support

Supported elements in widget descriptions:

| Element    | Markdown Syntax                |
| ---------- | ------------------------------ |
| Bold       | `**bold text**`                |
| Italic     | `*italicized text*`            |
| Code       | `` `code` ``                   |
| Link       | `[title](https://example.com)` |
| Code Block | Triple backticks               |

## Units System

### Unit Types

* **units2**: Default units (forces in kips for US)
* **unitsMks**: Metric units (kN, mm, MPa, kPa)
* **unitsFps**: Imperial units (forces in lb)

### Non-Unit-Aware Features

<Warning>
  The following features are NOT unit-aware and require extreme caution:

  * **All diagram code** - Must handle different unit conditions
  * **Solver inputs/outputs** - Units must be set manually
  * **Upgrade mappings** - No automatic unit conversion
  * **Dynamic lookups** - Units stripped from input tables
  * **Change material** - No unit consideration
  * **Specific MathJS functions** - Some functions incompatible with units
</Warning>

## Template Headers

Essential header attributes:

```json theme={null}
{
  "name": "Template Name",
  "icon": "data:image/svg+xml;base64,...",
  "references": "AS4100:2020, AS1170.1",
  "templateShortName": "TB",
  "code": "timberBeam",
  "buildingStandard": "AU",
  "changelog": "Added new features",
  "updateSeverity": "feature",
  "strictnessLevel": 2,
  "enableTypedLinks": true
}
```

## Presets

Presets provide quick access to common configurations:

### User Presets

Available to all users with default values for typical designs (e.g., floor joists, ridge beams)

### Test Only Presets

Internal testing presets visible with Shift+Click on "Add new calculation"

### Preset Structure

```json theme={null}
{
  "code": "floorJoist",
  "name": "Floor Joist",
  "icon": "base64_image_data",
  "values": {
    "span": {
      "default": 3000,
      "mks": 3000,
      "fps": 10
    }
  }
}
```
