# How to programmatically derive specific product instances from a configurable base model?

**URL:** <https://forum.sensmetry.com/t/how-to-programmatically-derive-specific-product-instances-from-a-configurable-base-model/381>\
**Category:** How-to Guides\
**Tags:** automator, sysmlv2\
**Created:** [January 20, 2026, 11:33am UTC](https://forum.sensmetry.com/t/how-to-programmatically-derive-specific-product-instances-from-a-configurable-base-model/381 "2026-01-20T11:33:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Susmitha\_Suresh](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/susmitha_suresh/32/131_2.png) [@Susmitha\_Suresh](https://forum.sensmetry.com/u/Susmitha_Suresh)\
**Post date:** [January 20, 2026, 11:33am UTC](https://forum.sensmetry.com/t/how-to-programmatically-derive-specific-product-instances-from-a-configurable-base-model/381/1 "2026-01-20T11:33:39Z")

</div>

Hi,

I’m implementing Product Line Engineering where I need to derive specific product instances from a configurable base model. My goal is to:

1. Load a base model with variable configuration (e.g., `[0..*]` multiplicity)

2. Read a feature configuration that specifies concrete values (e.g., `[4]`)

3. Programmatically generate a derived product model with fixed configuration

When I try to create the derived model using the API and serialize it with `syside.pprint()`, I get:

RuntimeError: Specialization can only be printed in KerML mode

**### Base Model (base.sysml)**

package VehiclePLE {

part def Wheel { }

// 150% base with variable multiplicity

part def Vehicle\_Base {

part wheels : Wheel [0..\*];

```auto
}

```

}

**### Feature Configuration (using PLEML library from SysAND)**

```sysml

#featureConfiguration def Sedan\_Config :\> VehicleProductLine {

```
#feature :>> useWheels \[4\]; // Specifies exactly 4 wheels for this product

```

}

```

**### Programmatic Derivation**

```python

# Load model and find base

model = syside.try\_load\_model([“base.sysml”, “features.sysml”])

base\_vehicle = # … find Vehicle\_Base

# Create derived 100% model

\_, sedan = pkg.children.append(syside.OwningMembership, syside.PartDefinition)

sedan.declared\_name = “Sedan\_100”

# Add specialization (:\> Vehicle\_Base)

sedan.heritage.insert(0, syside.Specialization, base\_vehicle)

# Add redefinition (part redefines wheels [4])

base\_wheels = # … find wheels in base\_vehicle

\_, wheels\_redef = sedan.children.append(syside.FeatureMembership, syside.PartUsage)

wheels\_redef.declared\_name = “wheels”

wheels\_redef.heritage.insert(0, syside.Redefinition, base\_wheels)

# Try to serialize - FAILS

output = syside.pprint(sedan) # RuntimeError: Specialization can only be printed in KerML mode

All API calls succeed and the model exists in memory, but serialization to SysML v2 fails.

**### Questions**

1. Is programmatic product derivation (creating specialized instances from a base model) a supported use case?

2. If so, how can I serialize the derived model to SysML v2 format?

Thanks!

---

<div class="post-metadata">

**Author:** ![Daumantas](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/daumantas/32/19_2.png) [@Daumantas](https://forum.sensmetry.com/u/Daumantas)\
**Post date:** [January 20, 2026, 11:49am UTC](https://forum.sensmetry.com/t/how-to-programmatically-derive-specific-product-instances-from-a-configurable-base-model/381/2 "2026-01-20T11:49:35Z")

</div>

Hi,

You want `syside.Subclassification` for `part def Sedan_100 :> Vehicle_Base`

 ![image](https://canada1.discourse-cdn.com/flex008/uploads/syside/original/1X/2e4b23cba60e322ed9a279693dab4fa3fb84d65b.png)

---

<div class="post-metadata">

**Author:** ![Susmitha\_Suresh](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/susmitha_suresh/32/131_2.png) [@Susmitha\_Suresh](https://forum.sensmetry.com/u/Susmitha_Suresh)\
**Post date:** [January 20, 2026, 2:03pm UTC](https://forum.sensmetry.com/t/how-to-programmatically-derive-specific-product-instances-from-a-configurable-base-model/381/3 "2026-01-20T14:03:05Z")

</div>

Thanks for the `Subclassification` solution - it works perfectly for creating derived models!

**A follow-up question: How can I programmatically set multiplicity values (e.g., `[4]`) in derived product models?**

**\*\*Goal:\*\*** Generate this programmatically:

```sysml

part def Sedan :\> Vehicle\_Base {

part wheels :\>\> Vehicle\_Base::wheels [4]; // Need to add [4]

}

```

**\*\*Current approach\*\*** - structure works, but missing multiplicity:

```python

# Create derived product

\_, sedan = pkg.children.append(syside.OwningMembership, syside.PartDefinition)

sedan.declared\_name = “Sedan”

sedan.heritage.insert(0, syside.Subclassification, vehicle\_base)

# Redefine wheels

\_, wheels = sedan.children.append(syside.FeatureMembership, syside.PartUsage)

wheels.declared\_name = “wheels”

wheels.heritage.insert(0, syside.Redefinition, base\_wheels)

# Output: part wheels :\>\> Vehicle\_Base::wheels; ✓ works, but missing [4]

```

**\*\*What I tried:\*\***

- Using `children.append(syside.OwningMembership, syside.MultiplicityRange)` → “MultiplicityRange can only be printed in KerML mode”

- Using `declared_multiplicity_member.add_member_element()` → same error when serializing

Is there a way to set multiplicity values programmatically that can be serialized to SysML v2?

---

<div class="post-metadata">

**Author:** ![Daumantas](https://yyz2.discourse-cdn.com/flex008/user_avatar/forum.sensmetry.com/daumantas/32/19_2.png) [@Daumantas](https://forum.sensmetry.com/u/Daumantas)\
**Post date:** [January 20, 2026, 2:23pm UTC](https://forum.sensmetry.com/t/how-to-programmatically-derive-specific-product-instances-from-a-configurable-base-model/381/4 "2026-01-20T14:23:19Z")

</div>

You will need to use `.declared_multiplicity` and `.bounds_expression_member`, e.g.

```python
# create multiplicity member
_, multi = part.declared_multiplicity_member.add_member_element()
# create multiplicity bounds expression (any expression is supported)
_, expr = multi.bounds_expression_member.set_member_element(syside.LiteralInteger)
expr.value = 4

```

Do note that SysML definitions cannot have multiplicity in textual syntax.
