We're excited to announce two new tools that extend Splice beyond the web interface: splice-py for programmatic harness generation in Python, and @splice-cad/embed for embedding interactive harness diagrams on your website.
Splice Python API (splice-py)
The splice-py Python library enables you to generate cable harness designs programmatically, perfect for automation, batch generation, and integration with existing engineering workflows.
Installation
pip install splice-py
Key Features
- Programmatic Harness Creation: Build complete harness designs using Python code
- Full BOM Control: Add connectors, wires, cables, and terminals programmatically
- Connection Mapping: Define wire connections between pins, cores, and flying leads
- JSON Export: Generate Splice-compatible JSON for import into Harness Builder
- API Upload: Directly upload generated harnesses to your Splice account
- Type Hints: Full type safety with comprehensive TypedDict definitions
Example Usage
"""
Power In harness example
Creates a power input cable with a 4-pin connector and flying leads
for connecting to a power source.
"""
from splice import Harness, ComponentType, Wire, WireColor, FlyingLead
# Create harness
harness = Harness(
name="Power In",
description="Power input cable with flying leads"
)
# Add 4-pin power connector (Kycon KPJX-PM-4S)
x1 = harness.add_component(
kind=ComponentType.CONNECTOR,
mpn="KPJX-PM-4S",
manufacturer="Kycon, Inc.",
positions=4,
position=(660, 30)
)
# Define wires
wire_red_20awg = Wire(
mpn="20UL1015STRRED",
manufacturer="Remington Industries",
awg=20,
color=WireColor.RED,
description="HOOK-UP STRND 20AWG RED"
)
wire_black_20awg = Wire(
mpn="20UL1007STRBLA",
manufacturer="Remington Industries",
awg=20,
color=WireColor.BLACK,
description="HOOK-UP STRND 20AWG BLACK"
)
# Create flying lead termination
flying_lead = FlyingLead(termination_type="stripped")
# Connect pins to flying leads
# Pin 1: Red wire (V+)
harness.connect(
x1.pin(1),
flying_lead,
wire=wire_red_20awg,
length_mm=300,
label_end1="V+"
)
# Pin 2: Black wire (GND)
harness.connect(
x1.pin(2),
flying_lead,
wire=wire_black_20awg,
length_mm=300,
label_end1="GND"
)
# Pin 3: Red wire (V+)
harness.connect(
x1.pin(3),
flying_lead,
wire=wire_red_20awg,
length_mm=300,
label_end1="V+"
)
# Pin 4: Black wire (GND)
harness.connect(
x1.pin(4),
flying_lead,
wire=wire_black_20awg,
length_mm=300,
label_end1="GND"
)
# Validate and save
result = harness.validate()
if result.valid:
harness.save("power_in.json")
harness.upload("your_api_key", True)
print("✓ Power In harness saved!")
else:
print("✗ Validation failed!")
for error in result.errors:
print(f" ERROR: {error}")
for warning in result.warnings:
print(f" WARNING: {warning}")
Getting your API key: Generate an API key from your Account Settings page. The key starts with "splice_" and provides programmatic access to upload harnesses to your account.
Use Cases
- Automated harness generation from CAD data, spreadsheets, or databases
- Batch processing for product families with similar wiring patterns
- Design validation and consistency checking across multiple harnesses
- Integration with PLM, ERP, or custom engineering tools
- Variant generation for different configurations or options
Documentation
- PyPI Package
- GitHub Repository
- Full API documentation available in the package README
Splice Embed Library (@splice-cad/embed)
The @splice-cad/embed JavaScript library allows you to embed interactive Splice harness diagrams directly on your website, documentation, or web application.
Installation
<script src="https://cdn.jsdelivr.net/npm/@splice-cad/embed@0.1.0-beta.2/dist/splice-embed.iife.js"></script>
Example Usage
<div id="harness-container"></div>
<script>
Splice.embed('harness-container', 'your-harness-id', {
width: '800px',
height: '600px',
showBOM: true,
theme: 'dark'
});
</script>
Use Cases
- Product documentation with interactive wiring diagrams
- Technical manuals with embedded harness designs
- Knowledge bases with searchable wiring information
- Manufacturing instructions with visual assembly guides
Sharing Options
To embed a harness, generate a share token from the harness settings page in Splice.
Documentation
Getting Started
Both tools are now publicly available:
- splice-py:
pip install splice-py - @splice-cad/embed: See installation options above
We're excited to see what you build with these tools! If you have questions, suggestions, or run into any issues, please reach out through GitHub Issues or email info@splice-cad.com.