Skip to content

Feature Request: Add Plugin Slot for Top/Bottom Surface Pattern Generation #2262

@privitera

Description

@privitera

Feature Request: Add Plugin Slot for Top/Bottom Surface Pattern Generation

Summary

Add a new plugin slot (e.g., Slot 202: SKIN_GENERATE) to enable custom top/bottom surface patterns via plugins, similar to how Slot 200 (INFILL_GENERATE) works for body infill patterns.

Problem Statement

Currently, the CuraEngine plugin system only supports custom infill patterns for body infill through Slot 200 (INFILL_GENERATE). Top and bottom surface patterns (top_bottom_pattern, roofing_pattern) are hardcoded to three options: "lines", "concentric", and "zigzag".

This limitation prevents plugin developers from:

  • Creating decorative surface patterns (Hilbert curves, Archimedean spirals, geometric tiles)
  • Implementing space-filling curves for top/bottom surfaces
  • Offering users more aesthetic and functional surface pattern options

Current Workaround

Users must set infill_density: 100% and top_layers: 0 to force the top surface to use custom infill patterns. This is inefficient and prevents proper infill/surface separation.

Proposed Solution

Add a new plugin slot for surface pattern generation:

Slot 202: SKIN_GENERATE

  • Purpose: Generate custom patterns for top/bottom surfaces
  • gRPC Service: SkinGenerateService (similar to existing proto file at skin/v0/skin.proto)
  • Settings Integration: Apply to top_bottom_pattern, roofing_pattern, top_bottom_pattern_0, bottom_pattern_initial_layer

Implementation Approach

  1. Define new slot ID in slot_id.proto:

    SKIN_GENERATE = 202;  // Generate skin (top/bottom surface) patterns
  2. Route surface pattern requests to plugins when custom patterns are registered via extend_category()

  3. Allow plugins to return empty responses to fall back to built-in patterns (same as Slot 200 behavior)

Use Cases

1. Decorative Top Surfaces

  • Print Hilbert curves, Archimedean spirals, or geometric patterns on top surfaces
  • Create visually appealing prints without post-processing
  • Enable artistic/customized prints

2. Functional Surface Patterns

  • Space-filling curves for better surface strength
  • Custom patterns optimized for specific materials
  • Pattern variations for different print requirements

3. Plugin Ecosystem Growth

  • Enables community-developed surface pattern plugins
  • Consistent with existing plugin architecture (Slot 200)
  • Reuses proven gRPC infrastructure

Technical Details

Existing Infrastructure

  • Proto file already exists: skin/v0/skin.proto defines SkinModifyService
  • Pattern registration via Python: definition.extend_category(pattern_key, pattern_label)
  • gRPC slot system: Well-established pattern with Slot 200

Required Changes

  1. Add SKIN_GENERATE = 202 to slot_id enum
  2. Create SkinGenerateService proto definition (or extend existing skin.proto)
  3. Route top_bottom_pattern setting to plugin when custom pattern registered
  4. Handle empty responses as fallback to built-in patterns

Backward Compatibility

  • No breaking changes - existing hardcoded patterns continue to work
  • Plugins opt-in by registering custom patterns
  • Falls back gracefully if plugin doesn't support pattern

Example Plugin Implementation

A plugin could register patterns like:

for pattern_key in ["top_bottom_pattern", "roofing_pattern"]:
    for definition in container.findDefinitions(key=pattern_key):
        for pattern in self.getSpaceFillingPatterns():
            definition.extend_category(
                pattern[0],
                pattern[1],
                plugin_id=self.getPluginId(),
                plugin_version=self.getVersion()
            )

Pattern examples:

  • Hilbert Curve
  • Archimedean Chords
  • Octagram Spiral
  • Flower of Life (tiled geometric)
  • Custom user-defined patterns

Benefits

  1. User Experience: More creative control over print aesthetics
  2. Plugin Ecosystem: Enables new plugin development opportunities
  3. Consistency: Aligns with existing Slot 200 architecture
  4. Flexibility: Community can experiment with surface patterns without forking CuraEngine

Related Work

  • Slot 200 (INFILL_GENERATE) demonstrates successful plugin-based pattern generation
  • Proto file skin/v0/skin.proto exists but not connected to any slot
  • Community interest in decorative surface patterns (PrusaSlicer, SuperSlicer have similar features)

Alternatives Considered

  1. Modify CuraEngine source directly - Requires forking and doesn't benefit community
  2. Use 100% infill workaround - Inefficient and loses infill/surface separation
  3. Post-process G-code - Complex, error-prone, loses CuraEngine optimizations

References

  • Current plugin system: Slot 200 (INFILL_GENERATE)
  • Existing proto: cura/plugins/slots/skin/v0/skin.proto
  • Slot ID definitions: cura/plugins/v0/slot_id.proto
  • Example plugin: CuraEngineTiledInfill (demonstrates pattern plugin architecture)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions