# Configuring Custom Attributes

Now that we have assembled our production line from individual machine assets, let’s enhance our organization system by adding custom attributes. Custom attributes can serve as digital “tags” that make our assemblies easier to search, organize, and automate workflows around. This becomes especially valuable as our digital twin projects scale to include multiple production lines, cells, and factory areas.

## **Two Example Attributes for Production Line Organization**

Your team will want to add Attributes that align to your catalog and workflow. Let’s make two here.

**ProductionLine_ID (String Attribute)**

What it is: A unique identifier that categorizes each assembly into a specific production line or manufacturing cell.

1. Select your **production line** assembly in the Stage panel
2. In the Properties panel, click **+ Add > Attribute**

![A production-line assembly selected in the Stage panel, with Add Attribute available in Properties.](materials-assembly/images/image54.jpg)
1. Set Name to **ProductionLine_ID**
2. Set Type to **string**
3. Enter a meaningful value like **PL_001_ElectronicsAssembly** or **Cell_A_PCB_Production**

![ProductionLine_ID set to Cell_A_PCB_Production in the assembly's raw USD properties.](materials-assembly/images/image26.png)

**Why This is Advantageous**

* Scripts can quickly find all assets belonging to a specific production line
* When reorganizing factory layouts, you can instantly identify which machines belong together

**Capacity_UnitsPerHour (Integer Attribute)**

What it is: The theoretical or actual production capacity of the assembly in units per hour.<br />
\\\\
How to Add:

1. With your assembly selected, click + **Add Attribute**
2. Set Name to **Capacity_UnitsPerHour**
3. Set Type to **int**
4. Enter the **production capacity** value (e.g., 450 for 450 units per hour)

![Assembly properties showing Capacity_UnitsPerHour set to 450 alongside ProductionLine_ID.](materials-assembly/images/image52.png)

---

**Why This is Advantageous**

* Quickly identify which production lines are capacity constraints
* Calculate ROI for additional equipment based on current capacity data
* Feed real capacity data into production scheduling simulations
* Compare actual throughput against theoretical capacity

---

## **Implementing the Attributes With Python**

![Script Editor showing an attribute-creation script and messages listing updated assembly prims.](materials-assembly/images/image28.png)

For larger projects with many assemblies, you can automate attribute creation using Python scripts. Copy the paths of the intended production-line roots from the Stage panel into `LINE_ROOT_PATHS`; do not include individual machine assemblies.

The example path must be replaced if your stage uses a different root. Each selected root must have `kind=assembly`. The script adds only missing attributes and preserves existing IDs and capacities, including the 450 value entered above. Choose the intended working authoring layer before running it.

```py
# Example script to add missing attributes to explicit production-line roots
from pxr import Usd, Sdf
import omni.usd

# Get the current stage
stage = omni.usd.get_context().get_stage()

LINE_ROOT_PATHS = ["/World/CL6_Line_Full"]  # Replace with your line-root paths

if not stage:
    print("No USD stage loaded.")
else:
    for path in LINE_ROOT_PATHS:
        prim = stage.GetPrimAtPath(path)
        if not prim or prim.GetMetadata("kind") != "assembly":
            print(f"Skipped {path}: select a valid production-line assembly root.")
            continue

        if not prim.HasAttribute("ProductionLine_ID"):
            line_id_attr = prim.CreateAttribute("ProductionLine_ID", Sdf.ValueTypeNames.String)
            line_id_attr.Set(f"PL_{prim.GetName()}")

        if not prim.HasAttribute("Capacity_UnitsPerHour"):
            capacity_attr = prim.CreateAttribute("Capacity_UnitsPerHour", Sdf.ValueTypeNames.Int)
            capacity_attr.Set(300)  # Example default; enter your actual capacity

        print(f"Checked attributes on: {prim.GetPath()}")


```

## **Advanced Use Cases Examples**

These attributes enable powerful downstream workflows:<br />
\\\\
**Automated Reporting**

* Generate capacity reports by querying all assemblies with Capacity_UnitsPerHour
* Create production line dashboards grouped by ProductionLine_ID

**Facility Optimization**

* Scripts can calculate total facility capacity by summing individual line capacities
* Identify underutilized lines for rebalancing workloads

**Integration with Manufacturing Systems**

* PLM systems can reference these IDs to link digital twins with real production data
* MES systems can use capacity data for intelligent work order routing

**Collaborative Workflows**

* Teams can filter views to show only their assigned production lines
* Maintenance schedules can be organized by production line groupings

---

## **Best Practices for Custom Attributes**

* **Use consistent naming conventions** (e.g., ProductionLine_ID, instead prodline_id)
* **Choose appropriate data types** (string for IDs, integers for counts, floats for measurements)
* **Document attribute meanings** in project README files
* **Validate attribute values** to ensure data quality
* **Consider future scalability** when designing attribute schemas

By implementing these attributes systematically across our digital twin assemblies, we create a foundation for intelligent automation, better organization, and seamless integration with broader manufacturing systems. As our virtual factory grows, these metadata investments will pay dividends in operational efficiency and data-driven decision making.
