Skip to content

archibate/dotfiles-opencode / skills/openscad

openscad

Verified

Create and render OpenSCAD 3D models. Generate preview images from multiple angles, extract customizable parameters, validate syntax, and export STL files for 3D printing.

FileKindSize
SKILL.mdskill md6.1 KB
examples/parametric_box.scadother2.6 KB
examples/phone_stand.scadother3.1 KB
tools/common.shexecutablescript1.1 KB
tools/export-stl.shexecutablescript1.1 KB
tools/extract-params.shexecutablescript4.3 KB
tools/multi-preview.shexecutablescript1.4 KB
tools/preview.shexecutablescript1.6 KB
tools/render-with-params.shexecutablescript2.1 KB
tools/validate.shexecutablescript954 B

tools/extract-params.sh

View on GitHub
#!/bin/bash
# Extract customizable parameters from an OpenSCAD file
# Usage: extract-params.sh input.scad [--json]
#
# Parses parameter declarations with special comments:
#   param = value;           // [min:max] Description
#   param = value;           // [min:step:max] Description  
#   param = value;           // [opt1, opt2] Description
#   param = value;           // Description only

set -e

if [ $# -lt 1 ]; then
    echo "Usage: $0 input.scad [--json]"
    exit 1
fi

INPUT="$1"
JSON_OUTPUT=false

if [ "$2" = "--json" ]; then
    JSON_OUTPUT=true
fi

if [ ! -f "$INPUT" ]; then
    echo "Error: File not found: $INPUT"
    exit 1
fi

# Extract parameters using Python for better parsing
extract_params() {
    python3 -c '
import sys
import re

filename = sys.argv[1]
in_block = 0

with open(filename, "r") as f:
    for line in f:
        # Track block depth (skip params inside modules/functions)
        in_block += line.count("{") - line.count("}")
        if in_block > 0:
            continue
            
        # Match: varname = value; // comment
        match = re.match(r"^\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*([^;]+);\s*(?://\s*(.*))?", line)
        if not match:
            continue
            
        var_name = match.group(1)
        value = match.group(2).strip()
        comment = match.group(3) or ""
        
        # Determine type
        if value in ("true", "false"):
            var_type = "boolean"
        elif re.match(r"^-?\d+$", value):
            var_type = "integer"
        elif re.match(r"^-?\d*\.?\d+$", value):
            var_type = "number"
        elif value.startswith("\"") and value.endswith("\""):
            var_type = "string"
            value = value[1:-1]  # Remove quotes
        elif value.startswith("["):
            var_type = "array"
        else:
            var_type = "expression"
        
        # Parse comment for range/options
        range_val = ""
        options_val = ""
        description = comment
        
        range_match = re.match(r"\[([^\]]+)\]\s*(.*)", comment)
        if range_match:
            bracket_content = range_match.group(1)
            description = range_match.group(2)
            
            # Check if numeric range (contains :) or options (contains ,)
            if ":" in bracket_content and not "," in bracket_content:
                range_val = bracket_content
            else:
                options_val = bracket_content
        
        # Output pipe-delimited
        print(f"{var_name}|{value}|{var_type}|{range_val}|{options_val}|{description}")
' "$INPUT"
}

if [ "$JSON_OUTPUT" = true ]; then
    echo "["
    first=true
    while IFS='|' read -r name value type range options description; do
        if [ "$first" = true ]; then
            first=false
        else
            echo ","
        fi
        
        # Escape quotes in values
        value=$(echo "$value" | sed 's/"/\\"/g')
        description=$(echo "$description" | sed 's/"/\\"/g')
        
        # Build JSON object
        printf '  {\n'
        printf '    "name": "%s",\n' "$name"
        printf '    "value": "%s",\n' "$value"
        printf '    "type": "%s"' "$type"
        
        if [ -n "$range" ]; then
            printf ',\n    "range": "%s"' "$range"
        fi
        if [ -n "$options" ]; then
            printf ',\n    "options": "%s"' "$options"
        fi
        if [ -n "$description" ]; then
            printf ',\n    "description": "%s"' "$description"
        fi
        printf '\n  }'
    done < <(extract_params)
    echo ""
    echo "]"
else
    echo "Parameters in: $INPUT"
    echo "==============================================="
    printf "%-20s %-15s %-10s %s\n" "NAME" "VALUE" "TYPE" "CONSTRAINT/DESC"
    echo "-----------------------------------------------"
    
    while IFS='|' read -r name value type range options description; do
        constraint=""
        if [ -n "$range" ]; then
            constraint="[$range]"
        elif [ -n "$options" ]; then
            constraint="[$options]"
        fi
        if [ -n "$description" ]; then
            if [ -n "$constraint" ]; then
                constraint="$constraint $description"
            else
                constraint="$description"
            fi
        fi
        
        printf "%-20s %-15s %-10s %s\n" "$name" "$value" "$type" "$constraint"
    done < <(extract_params)
fi
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall