Skip to content

Add example projects covering all OpenCAD API surfaces#2

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/build-example-projects-opencad
Draft

Add example projects covering all OpenCAD API surfaces#2
Copilot wants to merge 2 commits intomainfrom
copilot/build-example-projects-opencad

Conversation

Copy link
Contributor

Copilot AI commented Mar 8, 2026

Users had no runnable reference material to learn from or use as a starting point for building on top of OpenCAD's APIs. Adds an examples/ directory with six self-contained projects spanning every major API layer.

Examples

  • 01_hello_part/ — headless fluent API: box + cylinder + boolean cut + fillet + STEP export
  • 02_parametric_bracket/ — parameterised sketch → extrude → linear pattern → fillet; tunable constants at the top of the file
  • 03_rest_api_client/ — kernel REST API via stdlib urllib: health checks, list ops, create shapes, mesh fetch, topology, replay
  • 04_sketch_solver/ — solver REST API: solve, check, and diagnose (DOF, Jacobian sparsity, over/under-constrained variables)
  • 05_feature_tree/ — tree REST API: CRUD, rebuild with stale propagation, suppression, branching, and serialize/deserialize round-trip
  • 06_agent_chat/ — agent REST API: natural-language design prompts, multi-turn conversation, reasoning mode

Each example has a README.md describing prerequisites and expected output. Examples 01–02 run in-process with no services; 03–06 require the relevant backend services.

Tests

examples/tests/test_examples.py provides 7 pytest tests that import and execute the headless examples end-to-end, asserting on tree node count, operation set, node statuses, and that design parameters (pattern count, fillet radius) round-trip correctly.

# Example: run the bracket script and assert its feature DAG
reset_default_context()
mod = _load_example("02_parametric_bracket/bracket.py")
mod.main()

ctx = get_default_context()
operations = {n.operation for n in ctx.tree.nodes.values()}
assert "create_sketch" in operations
assert "linear_pattern" in operations
assert pattern_nodes[0].parameters["count"] == mod.HOLE_COUNT

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: deanhu0822 <86739329+deanhu0822@users.noreply.github.com>
Copilot AI changed the title [WIP] Add example projects for OpenCAD APIs Add example projects covering all OpenCAD API surfaces Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants