Duro API
ChangelogStatusApp
  • Welcome to Duro Dev Center
  • Getting Started
    • Introduction
    • Authentication
    • Hello World
  • Core Concepts
    • Components & Products
    • Documents
    • Change Orders
  • Advanced Topics
    • Searching and Filtering
    • Datarooms & RBAC
    • Webhooks
    • Error Handling
  • Library Configuration
    • Introduction to Duro's Config System
    • Category Registry
    • Revision Scheme
    • CPN Generation Scheme
    • CPN Schema Reference
  • Community
    • Developer Community
Powered by GitBook
On this page
  • Overview
  • Schema Structure
  • Basic Structure
  • Global Settings
  • Element Types
  • List Element
  • Constant Element
  • Numeric Counter
  • Hex Counter
  • Group Element
  • Example Configurations
  • Basic CPN Scheme
  • Advanced Two-Variable Scheme
  • Best Practices
  • Common Patterns
  • Category-Based Numbering
  • Family/Category Hierarchy
  • Optional Variants
  • Validation Rules
  • Troubleshooting
  • Reference
Export as PDF
  1. Library Configuration

CPN Generation Scheme

Overview

The Component Part Number (CPN) schema configuration system allows you to define structured rules for generating and validating part numbers in your PLM library. Using YAML configuration files, you can specify patterns, constraints, and validation rules that ensure consistency across your organization's component numbering system.

Schema Structure

A CPN schema configuration consists of three main sections:

  1. Version and Type Information

  2. Global Settings

  3. Element Definitions

  4. Examples

Basic Structure

version: "1.0"
schema_type: "cpn_generation_scheme"

settings:
  allow_override: false
  allow_freeform: false
  case_sensitive: true

elements:
  # Element definitions go here

examples:
  # Example CPNs go here

Global Settings

The settings section controls global behavior of your CPN scheme:

Setting
Type
Description

allow_override

boolean

Enables/disables manual CPN override capability

allow_freeform

boolean

Enables/disables support for freeform CPNs that don't follow the scheme

case_sensitive

boolean

Determines if CPNs should be treated as case-sensitive

Element Types

The elements section defines the components that make up your CPN. Each element represents a segment of the CPN and can be one of the following types:

List Element

Used for predefined sets of values, such as categories or families.

- type: "list"
  name: "category"
  required: true
  use: "id"  # Optional, specifies whether to use the id field from complex values
  values:
    - id: "410"
      name: "Screws"
      description: "Mechanical fasteners"
  validation:
    pattern: "^\\d{3}$"  # Optional regex pattern for additional validation

List elements can also reference external value sets using the template syntax:

values: ${{ duro.categories }}

Constant Element

Defines a fixed value, typically used for separators or prefixes.

- type: "constant"
  name: "separator"
  required: true
  value: "-"

Numeric Counter

Generates sequential numbers within a specified range.

- type: "numeric_counter"
  name: "sequence"
  required: true
  attachedTo: ["category"]  # Optional, ties counter to specific elements
  format:
    min_value: 1
    max_value: 9999

Hex Counter

Similar to numeric counter but generates hexadecimal values.

- type: "hex_counter"
  name: "sequence"
  required: true
  format:
    min_value: "0"
    max_value: "FF"

Group Element

Combines multiple elements into a logical group, useful for optional sections.

- type: "group"
  name: "suffix"
  required: false
  elements:
    - type: "constant"
      name: "suffix_delimiter"
      value: "."
    - type: "free"
      name: "variant"
      validation:
        pattern: "^[a-z]+$"
        max_length: 10

Example Configurations

Basic CPN Scheme

This example shows a simple category-based numbering scheme:

version: "1.0"
schema_type: "cpn_generation_scheme"

settings:
  allow_override: false
  allow_freeform: false
  case_sensitive: true

elements:
  - type: "list"
    name: "category"
    required: true
    use: "id"
    values:
      - id: "410"
        name: "Screws"
      - id: "591"
        name: "Resistors"
    validation:
      pattern: "^\\d{3}$"

  - type: "constant"
    name: "separator"
    required: true
    value: "-"

  - type: "numeric_counter"
    name: "sequence"
    required: true
    attachedTo: ["category"]
    format:
      min_value: 1
      max_value: 9999

examples:
  - "410-0001"  # Screws
  - "591-0042"  # Resistors

This scheme generates CPNs like 410-0001, where:

  • 410 is the category code

  • - is a constant separator

  • 0001 is a sequential number

Advanced Two-Variable Scheme

Here's a more complex scheme with multiple variables and an optional suffix (for something like a variant):

version: "1.0"
schema_type: "cpn_generation_scheme"

settings:
  allow_override: false
  allow_freeform: false
  case_sensitive: true

elements:
  - type: "list"
    name: "family"
    required: true
    values: ${{ duro.families }}

  - type: "constant"
    name: "separator"
    required: true
    value: "-"

  - type: "list"
    name: "category"
    required: true
    values: ${{ duro.categories }}

  - type: "numeric_counter"
    name: "sequence"
    required: true
    attachedTo: ["family", "category"]
    format:
      min_value: 1
      max_value: 999

  - type: "group"
    name: "suffix"
    required: false
    elements:
      - type: "constant"
        name: "suffix_delimiter"
        value: "."
      - type: "free"
        name: "variant"
        validation:
          pattern: "^[a-z]+$"
          max_length: 10

examples:
  - "DOGS-410-0001"
  - "CATS-591-0042.test"

This scheme generates CPNs like DOGS-410-0001 or CATS-591-0042.test, where:

  • First segment is a family code

  • Second segment is a category code

  • Third segment is a sequence number

  • Optional suffix after a dot for variants

Best Practices

  1. Start Simple: Begin with a basic scheme and add complexity as needed.

  2. Use Clear Names: Choose descriptive names for elements to make the configuration self-documenting.

  3. Validate Patterns: Always include regex patterns for list values to ensure consistency.

  4. Include Examples: Provide comprehensive examples that cover all possible variations of your scheme.

  5. Consider Scale: Set appropriate ranges for counters based on expected volume.

  6. Document Meanings: Include descriptions for list values to make their purpose clear.

Common Patterns

Category-Based Numbering

elements:
  - type: "list"
    name: "category"
    required: true
  - type: "numeric_counter"
    name: "sequence"
    attachedTo: ["category"]

Family/Category Hierarchy

elements:
  - type: "list"
    name: "family"
  - type: "list"
    name: "category"
  - type: "numeric_counter"
    name: "sequence"
    attachedTo: ["family", "category"]

Optional Variants

elements:
  # ... main elements ...
  - type: "group"
    name: "suffix"
    required: false
    elements:
      - type: "constant"
        value: "."
      - type: "free"
        validation:
          pattern: "^[a-z]+$"

Validation Rules

  • List values can have additional regex validation patterns

  • Free text elements must specify max length and allowed patterns

  • Counter ranges must be appropriate for their use case

  • All required elements must be included in the sequence

  • Group elements can contain their own validation rules

Troubleshooting

Common issues and their solutions:

  1. Invalid Patterns: Ensure regex patterns are properly escaped in YAML

  2. Counter Overflow: Check that counter ranges are sufficient for your needs

  3. Missing Required Elements: Verify all required elements are included

  4. Case Sensitivity: Consider implications of case-sensitive settings

  5. Validation Conflicts: Ensure patterns don't conflict with other rules

Reference

PreviousRevision SchemeNextCPN Schema Reference

Last updated 5 months ago

For the complete JSON schema definition and all available options, refer to the .

CPN Schema Reference