Files
kicad-mcp-server/python/commands/connection_schematic.py
KiCAD MCP Bot e4c7119c51 feat: Week 1 complete - Linux support + IPC API prep
🎉 Major v2.0 rebuild kickoff - Week 1 accomplished!

## Highlights

### Cross-Platform Support 🌍
-  Linux primary platform (Ubuntu/Debian tested)
-  Windows fully supported
-  macOS experimental support
-  Platform-agnostic path handling (XDG spec)
-  Auto-detection of KiCAD installation

### Infrastructure 🏗️
-  GitHub Actions CI/CD pipeline
-  Pytest framework with 20+ tests
-  Pre-commit hooks (Black, MyPy, ESLint)
-  Automated Linux installation script
-  Enhanced npm scripts

### IPC API Migration Prep 🚀
-  Comprehensive migration plan (30 pages)
-  Backend abstraction layer (800+ lines)
-  Factory pattern with auto-detection
-  SWIG backward compatibility wrapper
-  IPC backend skeleton ready

### Documentation 📚
-  Updated README (Linux installation)
-  CONTRIBUTING.md guide
-  Linux compatibility audit
-  IPC API migration plan
-  Session summaries
-  Platform-specific config templates

## Files Changed

- 27 files created
- ~3,000 lines of code/docs
- 8 comprehensive documentation pages
- 20+ unit tests
- 5 abstraction layer modules

## Next Steps

- Week 2: IPC API migration (project.py → component.py → routing.py)
- Migrate from deprecated SWIG to official IPC API
- JLCPCB/Digikey integration prep

🤖 Generated with Claude Code
https://claude.com/claude-code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 20:48:00 -04:00

92 lines
4.6 KiB
Python

from skip import Schematic
# Wire and Net classes might not be directly importable in the current version
import os
class ConnectionManager:
"""Manage connections between components"""
@staticmethod
def add_wire(schematic: Schematic, start_point: list, end_point: list, properties: dict = None):
"""Add a wire between two points"""
try:
wire = schematic.add_wire(start=start_point, end=end_point)
# kicad-skip wire properties are limited, but we can potentially
# add graphical properties if needed in the future.
print(f"Added wire from {start_point} to {end_point}.")
return wire
except Exception as e:
print(f"Error adding wire: {e}")
return None
@staticmethod
def add_connection(schematic: Schematic, source_ref: str, source_pin: str, target_ref: str, target_pin: str):
"""Add a connection between component pins"""
# kicad-skip handles connections implicitly through wires and labels.
# This method would typically involve adding wires and potentially net labels
# to connect the specified pins.
# A direct 'add_connection' between pins isn't a standard kicad-skip operation
# in the way it is in some other schematic tools.
# We will need to implement this logic by finding the component pins
# and adding wires/labels between their locations. This is more complex
# and might require pin location information which isn't directly
# exposed in a simple way by default in kicad-skip Symbol objects.
# For now, this method will be a placeholder or require a more advanced
# implementation based on how kicad-skip handles net connections.
# A common approach is to add wires between graphical points and then
# add net labels to define the net name.
print(f"Attempted to add connection between {source_ref}/{source_pin} and {target_ref}/{target_pin}. This requires advanced implementation.")
return False # Indicate not fully implemented yet
@staticmethod
def remove_connection(schematic: Schematic, connection_id: str):
"""Remove a connection"""
# Removing connections in kicad-skip typically means removing the wires
# or net labels that form the connection.
# This method would need to identify the relevant graphical elements
# based on a connection identifier (which we would need to define).
# This is also an advanced implementation task.
print(f"Attempted to remove connection with ID {connection_id}. This requires advanced implementation.")
return False # Indicate not fully implemented yet
@staticmethod
def get_net_connections(schematic: Schematic, net_name: str):
"""Get all connections in a named net"""
# kicad-skip represents nets implicitly through connected wires and net labels.
# To get connections for a net, we would need to iterate through wires
# and net labels to build a list of connected pins/points.
# This requires traversing the schematic's graphical elements and understanding
# how they form nets. This is an advanced implementation task.
print(f"Attempted to get connections for net '{net_name}'. This requires advanced implementation.")
return [] # Return empty list for now
if __name__ == '__main__':
# Example Usage (for testing)
from schematic import SchematicManager # Assuming schematic.py is in the same directory
# Create a new schematic
test_sch = SchematicManager.create_schematic("ConnectionTestSchematic")
# Add some wires
wire1 = ConnectionManager.add_wire(test_sch, [100, 100], [200, 100])
wire2 = ConnectionManager.add_wire(test_sch, [200, 100], [200, 200])
# Note: add_connection, remove_connection, get_net_connections are placeholders
# and require more complex implementation based on kicad-skip's structure.
# Example of how you might add a net label (requires finding a point on a wire)
# from skip import Label
# if wire1:
# net_label_pos = wire1.start # Or calculate a point on the wire
# net_label = test_sch.add_label(text="Net_01", at=net_label_pos)
# print(f"Added net label 'Net_01' at {net_label_pos}")
# Save the schematic (optional)
# SchematicManager.save_schematic(test_sch, "connection_test.kicad_sch")
# Clean up (if saved)
# if os.path.exists("connection_test.kicad_sch"):
# os.remove("connection_test.kicad_sch")
# print("Cleaned up connection_test.kicad_sch")