Component Instances

Overview

This guide covers how to create and use library component instances in ParamML - a fundamental feature for building reusable, parametric components.

What you'll learn:

  • What object instances are

  • How to create instances

  • What gets copied to instances

  • Basic usage patterns

  • Simple nested instances

For advanced topics (Export dependencies, complex nesting, debugging): → See AI-Export.md


What are Object Instances?

An object instance is created when you use a Library Component as a building block in your own component.

Think of it like:

  • Component Definition = Blueprint/Template (e.g., "Cube")

  • Instance = Using that blueprint (e.g., "MyCube")

Analogy

Like a cookie cutter (component) making multiple cookies (instances).


Creating an Instance

Basic Syntax

To create an instance, use the component name as the T (Type) attribute:

Simple Example

Simple Example

Component definition:

Creating instances:

Using instances:


What Gets Copied to an Instance

When you create an instance, only specific content appears:

✅ What Gets Copied

  1. Input parameters (Role="Input")

  2. Everything inside <O T="Export">

❌ What Does NOT Get Copied

  • Parameters without Role="Input" that are outside Export

  • Objects outside Export

  • Geometry (Volume, Surface, Point objects)

  • Internal calculations outside Export

Example: What Appears

Component definition:

Instance:

What you can access:


The Export Object

The <O T="Export"> object controls what is accessible when someone creates an instance of your component.

Why Export Exists

Export creates a clean interface - only exposing what users need, hiding implementation details.

Without Export:

  • ❌ Everything would be accessible

  • ❌ Implementation details exposed

  • ❌ Hard to refactor without breaking code

  • ❌ Messy, confusing interface

With Export:

  • ✅ Clean, simple interface

  • ✅ Hide complexity

  • ✅ Can change internals without breaking users

  • ✅ Clear what's intended for external use

Basic Export Example

Instance sees only:

⚠️ Note: The weight calculation has a dependency issue. See AI-Export.md for details on the Dependency Rule.


Setting Instance Parameters

Set Input Values

Use Expressions

Instance parameters can be expressions:

Reference Other Instances


Nested Instances (Simple)

Instances can contain other instances.

Simple Nesting

Building block:

Component using Bolt:

Using Connection:

Key point: The nested Bolt instance must be inside Export for external access.


The Exported="1" Attribute

You'll see Exported="1" on nested instances.

How It Works

In component definition (what you write):

In instance (system generates):

What it means: Marks the object as an exported instance, allowing nested access.

Rule: Never write Exported="1" - the system adds it automatically.


Common Patterns

Pattern 1: Multiple Instances of Same Component

Pattern 2: Instances with Different Parameters

Pattern 3: Instance Coordinates from Another Instance

Quick Troubleshooting

Problem: "Can't access parameter from instance"

Check:

  1. Is the parameter inside <O T="Export">?

  2. Does the parameter have Role="Input"?

  3. If neither → it's not accessible from outside

Solution: Move parameter inside Export or add Role="Input"

Problem: "Can't access nested object"

Check:

  1. Is the nested object instance inside <O T="Export">?

Solution: Move the nested object instance inside Export

Problem: "Calculation gives wrong value in instance"

Likely cause: Missing dependency (parameter referenced but not exported)

Solution: See AI-Export.md for the Dependency Rule


Next Steps

You now know:

  • ✅ How to create instances

  • ✅ What gets copied to instances

  • ✅ How to use instance values

  • ✅ Simple nested instances


Quick Reference

Create Instance

What Gets Copied

  • Role="Input" parameters

  • ✅ Everything inside <O T="Export">

  • ❌ Everything else

Access Instance Values

Export for Accessibility

Last updated