### Start Frontend Development Server Source: https://github.com/caid-technologies/opencad/blob/main/README.md Install frontend dependencies and start the development server for the OpenCAD viewport. ```bash cd opencad_viewport pnpm install pnpm dev # → http://localhost:5173 ``` -------------------------------- ### Setup Development Environment Source: https://github.com/caid-technologies/opencad/blob/main/CONTRIBUTING.md Installs project dependencies using uv for Python and pnpm for the viewport. Run this command to set up your local development environment. ```bash uv sync --extra test --extra server cd opencad_viewport pnpm install ``` -------------------------------- ### Install and Run OpenCAD Viewport Development Server Source: https://github.com/caid-technologies/opencad/blob/main/PRODUCTION.md Install npm dependencies and start the development server for the OpenCAD viewport. This is useful for local development and validation. ```bash cd opencad_viewport npm install npm run dev ``` -------------------------------- ### Install Optional OpenCAD Integrations Source: https://github.com/caid-technologies/opencad/blob/main/README.md Install optional integrations like OCCT, LLM, or a full suite using uv sync. ```bash uv sync --extra occt ``` ```bash uv sync --extra llm ``` ```bash uv sync --extra full ``` -------------------------------- ### Install OpenCAD for Local Development Source: https://github.com/caid-technologies/opencad/blob/main/README.md Install dependencies and copy the environment file for local development from the repository. ```bash uv sync --extra test --extra server cp .env.example .env ``` -------------------------------- ### Run Development Script Source: https://github.com/caid-technologies/opencad/blob/main/README.md Start the backend and frontend development servers together from the repository root. ```bash cd opencad_viewport pnpm install cd .. ./scripts/run_dev.sh ``` -------------------------------- ### Start Backend Services Source: https://github.com/caid-technologies/opencad/blob/main/README.md Start the backend services using uvicorn. Each service runs on its own port. ```bash cd backend uv run --no-sync python -m uvicorn api:app --reload --port 8000 ``` -------------------------------- ### Run OpenCAD Example Script Source: https://github.com/caid-technologies/opencad/blob/main/README.md Execute an example script from the repository root using the OpenCAD CLI. This command allows exporting the generated model to a STEP file and saving the feature tree. ```bash python -m opencad.cli run examples/hardware_mounting_bracket.py \ --export bracket.step \ --tree-output bracket-tree.json ``` -------------------------------- ### Install OpenCAD with pip Source: https://github.com/caid-technologies/opencad/blob/main/README.md Use this command to install the packaged version of OpenCAD from a PyPI release. ```bash uv pip install opencad ``` -------------------------------- ### Headless Scripting with OpenCAD API Source: https://github.com/caid-technologies/opencad/blob/main/README.md Example of using the OpenCAD in-process API for parametric design and exporting to STEP format. ```python from opencad import Part, Sketch part = Part() sketch = Sketch().rect(10, 20).circle(3, subtract=True) part.extrude(sketch, depth=5).fillet(edges="top", radius=0.5) part.export("output.step") ``` -------------------------------- ### Sync and Run Python with OpenCAD Source: https://github.com/caid-technologies/opencad/blob/main/docs/RECONSTRUCTION_AND_UPGRADE_PLAN.md Synchronizes project dependencies and runs a Python script to verify OpenCAD installation and version. ```powershell uv sync --extra test --extra server uv run --no-sync python -c "import opencad; print(opencad.__version__, opencad.__file__)" opencad --help ``` -------------------------------- ### Configure Solver Backend Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md Set the environment variable to select the desired solver backend. 'auto' prefers SolveSpace if available. ```bash export OPENCAD_SOLVER_BACKEND=solvespace|python|auto ``` -------------------------------- ### Build Frontend Docker Image with Custom Args Source: https://github.com/caid-technologies/opencad/blob/main/README.md Build the frontend Docker image with custom build arguments for API URL and mock modes. ```bash docker build \ -f opencad_viewport/Dockerfile \ -t opencad-frontend \ --build-arg VITE_BASE_URL=http://localhost:8000 \ --build-arg VITE_USE_MOCK=false \ --build-arg VITE_USE_CHAT_MOCK=false \ opencad_viewport ``` -------------------------------- ### Build Model with CLI Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md Use the CLI to load a tree JSON model and rebuild it in-process. ```bash opencad build model.json --output model.built.json ``` -------------------------------- ### Build OpenCAD Backend Docker Image Source: https://github.com/caid-technologies/opencad/blob/main/README.md Build the Docker image for the OpenCAD backend from the repository root. ```bash docker build -f backend/Dockerfile -t opencad-backend . ``` -------------------------------- ### Build OpenCAD Frontend Docker Image Source: https://github.com/caid-technologies/opencad/blob/main/README.md Build the Docker image for the OpenCAD frontend from the viewport directory. ```bash docker build -f opencad_viewport/Dockerfile -t opencad-frontend opencad_viewport ``` -------------------------------- ### Run Development Script with Custom Ports Source: https://github.com/caid-technologies/opencad/blob/main/README.md Override default backend and frontend host/port configurations when running the development script. ```bash BACKEND_HOST=0.0.0.0 BACKEND_PORT=8000 FRONTEND_HOST=0.0.0.0 FRONTEND_PORT=5173 ./scripts/run_dev.sh ``` -------------------------------- ### Verify Changes Before Proposing Source: https://github.com/caid-technologies/opencad/blob/main/CONTRIBUTING.md Runs pytest for Python code, and pnpm test and build for the viewport. Execute these commands to ensure your changes meet the project's quality standards. ```bash uv run --no-sync python -m pytest cd opencad_viewport pnpm test pnpm build ``` -------------------------------- ### Run Fluent Scripts with CLI Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md Execute fluent scripts in-process using the CLI and optionally export STEP and tree JSON. ```bash opencad run model.py --export output.step --tree-output output-tree.json ``` -------------------------------- ### Viewport Client Mock Configuration Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md Configure the viewport client to use mock data for geometry and solver flows by setting the VITE_USE_MOCK environment variable. Chat defaults to the live agent service, with an option to enable a mocked chat path. ```typescript const client = new ApiClient({ useMock: VITE_USE_MOCK }); ``` -------------------------------- ### OpenCAD CLI Commands Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md Command-line interface for building and running OpenCAD models. ```APIDOC ## CLI for CI/CD ### `opencad build model.json --output model.built.json` - Loads a tree JSON model and rebuilds it in-process. ### `opencad run model.py --export output.step --tree-output output-tree.json` - Executes fluent scripts in-process and optionally exports STEP + tree JSON. ``` -------------------------------- ### Run Pytest and Viewport Tests Source: https://github.com/caid-technologies/opencad/blob/main/docs/RECONSTRUCTION_AND_UPGRADE_PLAN.md Executes the Python backend tests using pytest and the frontend viewport tests using pnpm. ```powershell uv run --no-sync python -m pytest cd opencad_viewport pnpm install pnpm test pnpm build ``` -------------------------------- ### Run Pytest for OpenCAD Source: https://github.com/caid-technologies/opencad/blob/main/PRODUCTION.md Execute the test suite for the OpenCAD project using pytest. ```bash pytest ``` -------------------------------- ### Run OpenCAD Frontend Docker Container Source: https://github.com/caid-technologies/opencad/blob/main/README.md Run the OpenCAD frontend in a Docker container, exposing port 5173. ```bash docker run --rm -p 5173:80 opencad-frontend ``` -------------------------------- ### OpenCAD Fluent API Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md The fluent API provides methods for creating parts and sketches. Users can import `Part` and `Sketch` from `opencad`. ```APIDOC ## OpenCAD Fluent API ### `opencad.part.Part` - Kernel-backed v1 methods for primitives, booleans, extrude, edge/face ops, patterns, and export. ### `opencad.sketch.Sketch` - Fluent segment builder (`line`, `rect`, `circle`) that materializes via `create_sketch`. ### Public import surface: - `from opencad import Part, Sketch` ``` -------------------------------- ### Run OpenCAD Backend Docker Container Source: https://github.com/caid-technologies/opencad/blob/main/README.md Run the OpenCAD backend API in a Docker container, exposing port 8000. ```bash docker run --rm -p 8000:8000 opencad-backend ``` -------------------------------- ### OpenCAD CLI Commands Source: https://github.com/caid-technologies/opencad/blob/main/README.md Basic CLI commands for OpenCAD. Use 'build' to process a model JSON into a built JSON, and 'run' to execute a Python script, optionally exporting to STEP and tree output formats. ```bash opencad build model.json --output model.built.json ``` ```bash opencad run model.py --export output.step --tree-output output-tree.json ``` -------------------------------- ### RuntimeContext for Headless Operation Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md The RuntimeContext orchestrates kernel, operation registry, and feature tree in a single process. It manages feature IDs, serialization, and supports in-process agent service execution. ```python from opencad.runtime import RuntimeContext context = RuntimeContext() context.chat(message="Create a cube.") ``` -------------------------------- ### Viewport Build Status Source: https://github.com/caid-technologies/opencad/blob/main/docs/RECONSTRUCTION_AND_UPGRADE_PLAN.md Displays the build status of the OpenCAD viewport. ```text 229 passed, 17 skipped viewport tests: 3 passed viewport build: passed ``` -------------------------------- ### OpenCAD 0.1.1 Contract Components Source: https://github.com/caid-technologies/opencad/blob/main/docs/RECONSTRUCTION_AND_UPGRADE_PLAN.md Introduces key components for the new OpenCAD contract, including `DesignArtifact` for storing design data and `DesignPatch` for applying parameter changes. ```python DesignArtifact stores the feature tree, named design parameters, and simulation tags. DesignPatch stores structured parameter patches from SimCorrect. Part.export_design_artifact(...) writes the JSON handoff file. apply_design_patch(...) applies parameter patches without mutating the original artifact. ``` -------------------------------- ### Export Design Artifact with OpenCAD Source: https://github.com/caid-technologies/opencad/blob/main/README.md Export a versioned JSON artifact for SimCorrect. This artifact includes the feature tree, named parameters, and simulation tags. SimCorrect uses these to return structured parameter patches. ```python from opencad import Part, Sketch part = Part(name="forearm").extrude(Sketch().rect(30, 4), depth=4) part.export_design_artifact( "caid-design.json", artifact_id="forearm-demo", parameters={"forearm_length": {"value": 0.30, "unit": "m", "role": "geometry"}}, simulation_tags=[ {"name": "right_forearm", "kind": "body", "target": "r_forearm"}, {"name": "forearm_length", "kind": "parameter", "target": "link2_length"}, ], ) ``` -------------------------------- ### OpenCAD Script or Feature Tree Source: https://github.com/caid-technologies/opencad/blob/main/docs/RECONSTRUCTION_AND_UPGRADE_PLAN.md Represents the input to the validated design artifact process. ```text OpenCAD script or feature tree -> validated design artifact -> real geometry export or MJCF-oriented geometry description -> SimCorrect simulation scenes -> correction output as parameter changes or feature-tree patches ``` -------------------------------- ### Agent Service Chat API Input Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md The /chat endpoint accepts a message, current tree state, conversation history, and reasoning flag. Optional parameters include LLM provider, model, and a flag to generate code instead of executing tools. ```python { "message": "str", "tree_state": FeatureTree, "conversation_history": [], "reasoning": bool, "llm_provider": str | None, # optional "llm_model": str | None, # optional "generate_code": bool # optional } ``` -------------------------------- ### OpenCAD Agent API Source: https://github.com/caid-technologies/opencad/blob/main/PRODUCTION.md Endpoints for the OpenCAD agent service, handling chat interactions. ```APIDOC ## GET /healthz ### Description Health check endpoint for the agent service. ### Method GET ### Endpoint /healthz ``` ```APIDOC ## POST /chat ### Description Sends a message to the agent for chat interaction. ### Method POST ### Endpoint /chat ``` -------------------------------- ### OpenCAD Solver API Source: https://github.com/caid-technologies/opencad/blob/main/PRODUCTION.md Endpoints for the OpenCAD solver service, handling sketch solving and diagnostics. ```APIDOC ## GET /healthz ### Description Health check endpoint for the solver service. ### Method GET ### Endpoint /healthz ``` ```APIDOC ## GET /backend ### Description Retrieves information about the active solver backend and its capabilities. ### Method GET ### Endpoint /backend ``` ```APIDOC ## POST /sketch/solve ### Description Solves a given sketch. ### Method POST ### Endpoint /sketch/solve ``` ```APIDOC ## POST /sketch/check ### Description Checks the validity of a given sketch. ### Method POST ### Endpoint /sketch/check ``` ```APIDOC ## POST /sketch/diagnose ### Description Performs constraint-graph introspection for a sketch, providing DOF and Jacobian analysis. ### Method POST ### Endpoint /sketch/diagnose ``` -------------------------------- ### CAID Simulation Tag Structure (v1) Source: https://github.com/caid-technologies/opencad/blob/main/docs/CAID_ARTIFACT_CONTRACT.md Defines the structure for simulation tags, mapping design names to simulator names. For schema version 1, `kind="parameter"` tags link simulator parameters to OpenCAD design parameters. ```json { "name": "forearm_length", "kind": "parameter", "target": "link2_length" } ``` -------------------------------- ### OpenCAD Tree API Source: https://github.com/caid-technologies/opencad/blob/main/PRODUCTION.md Endpoints for the OpenCAD tree service, managing the assembly tree structure. ```APIDOC ## GET /healthz ### Description Health check endpoint for the tree service. ### Method GET ### Endpoint /healthz ``` -------------------------------- ### Viewport Application Data Contracts Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md Defines the data contracts for interacting with the viewport application, including fetching mesh data, tree structure, and updating features. ```APIDOC ## Mesh Contract ### Description Retrieves mesh data for a given shape ID. ### Method GET ### Endpoint /shape/{id}/mesh ### Response #### Success Response (200) - **vertices** (array) - Vertex data. - **faces** (array) - Face data. - **normals** (array) - Normal data. ``` ```APIDOC ## Tree Contract ### Description Retrieves the entire feature tree structure. ### Method GET ### Endpoint /tree ### Response #### Success Response (200) - **FeatureTree** (object) - The complete feature tree. ``` ```APIDOC ## Feature Updates ### Description Endpoints for updating and managing features within the tree. ### Method POST, PATCH ### Endpoint - /feature - /feature/{id} - /trees/{tree_id}/nodes/{node_id}/typed-parameters - /trees/{tree_id}/nodes/{node_id}/suppress - /trees/{tree_id}/branches - /trees/{tree_id}/branches/{branch_name}/switch - /trees/{tree_id}/solver/{sketch_id} ``` -------------------------------- ### CAID Design Artifact Parameter Structure (v1) Source: https://github.com/caid-technologies/opencad/blob/main/docs/CAID_ARTIFACT_CONTRACT.md Illustrates the structure for a single design parameter within a CAID artifact. Each parameter must have a name, value, and can optionally include unit, role, and feature ID. ```json { "forearm_length": { "name": "forearm_length", "value": 0.25, "unit": "m", "role": "geometry", "feature_id": "feat-forearm" } } ``` -------------------------------- ### Check Backend Service Health Source: https://github.com/caid-technologies/opencad/blob/main/README.md Check the health status of different OpenCAD backend services using curl. ```bash curl -s http://127.0.0.1:8000/kernel/healthz # → {"status":"ok"} ``` ```bash curl -s http://127.0.0.1:8000/agent/healthz ``` ```bash curl -s http://127.0.0.1:8000/solver/healthz ``` ```bash curl -s http://127.0.0.1:8000/tree/healthz ``` -------------------------------- ### OpenCAD Kernel API Source: https://github.com/caid-technologies/opencad/blob/main/PRODUCTION.md Endpoints for the OpenCAD kernel service, handling operations and schema. ```APIDOC ## GET /healthz ### Description Health check endpoint for the kernel service. ### Method GET ### Endpoint /healthz ``` ```APIDOC ## GET /operations ### Description Lists available operations supported by the kernel. ### Method GET ### Endpoint /operations ``` ```APIDOC ## GET /operations/{name}/schema ### Description Retrieves the schema for a specific operation. ### Method GET ### Endpoint /operations/{name}/schema ### Parameters #### Path Parameters - **name** (string) - Required - The name of the operation. ``` ```APIDOC ## POST /operations/{name} ### Description Executes a specified operation. ### Method POST ### Endpoint /operations/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the operation to execute. ### Operations - `create_assembly_mate` - `delete_assembly_mate` - `list_assembly_mates` ``` -------------------------------- ### Agent Service Chat API Output Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md The /chat endpoint returns a human-readable response, optionally generated code, a list of executed operations, and the new state of the feature tree. ```python { "response": "str", "generated_code": str | None, "operations_executed": [], "new_tree_state": FeatureTree } ``` -------------------------------- ### Constraint Solving API Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md API endpoints and operations related to constraint solving and diagnostics. ```APIDOC ## Constraint Solving Architecture ### Pluggable Solver Backend - Backend selection: `OPENCAD_SOLVER_BACKEND=solvespace|python|auto` (auto prefers SolveSpace). ### Constraint-Graph Introspection #### `POST /sketch/diagnose` - Returns `ConstraintDiagnostics` with fields: `dof`, `status`, `jacobian`, `variables`, `constraints`, `over_constrained_ids`, `under_constrained_variables`. ### 3-D Assembly Mates (Phase 1) - `create_assembly_mate` — validates entity references, creates mate in `MateStore`. - `delete_assembly_mate` — removes a mate by ID. - `list_assembly_mates` — lists all mates, optionally filtered by entity involvement. - Supported mate types: `coincident`, `concentric`, `distance`, `angle`, `parallel`, `perpendicular`. ``` -------------------------------- ### CAID Design Artifact Schema (v1) Source: https://github.com/caid-technologies/opencad/blob/main/docs/CAID_ARTIFACT_CONTRACT.md Defines the required top-level fields for a CAID design artifact. Includes schema version, artifact ID, producer information, creation timestamp, feature tree, parameters, and simulation tags. ```json { "schema_version": 1, "artifact_id": "simcorrect-problem1-forearm", "producer": {"name": "opencad", "version": "0.1.1"}, "created_at": "2026-04-24T00:00:00Z", "feature_tree": {"root_id": "root", "nodes": {}}, "parameters": {}, "simulation_tags": [] } ``` -------------------------------- ### Agent Service API Source: https://github.com/caid-technologies/opencad/blob/main/ARCHITECTURE.md Defines the API endpoints for the Agent Service, responsible for processing natural language requests and managing feature execution. ```APIDOC ## Health Check ### Description Checks the health status of the agent service. ### Method GET ### Endpoint /healthz ``` ```APIDOC ## Chat Endpoint ### Description Accepts natural language messages, processes them with the current tree state, and returns a response, potentially including generated code and executed operations. ### Method POST ### Endpoint /chat ### Parameters #### Request Body - **message** (str) - The user's natural language input. - **tree_state** (FeatureTree) - The current state of the feature tree. - **conversation_history** (array) - The history of the conversation. - **reasoning** (bool) - Whether to enable reasoning. - **llm_provider** (str | null) - Optional LLM provider for code generation. - **llm_model** (str | null) - Optional LLM model for code generation. - **generate_code** (bool) - If true, returns example-style Python instead of executing tools. ### Response #### Success Response (200) - **response** (str) - Human-readable response. - **generated_code** (str | null) - Generated code if `generate_code` is true. - **operations_executed** (array) - List of operations executed. - **new_tree_state** (FeatureTree) - The updated state of the feature tree. ``` -------------------------------- ### CAID Design Patch Schema (v1) Source: https://github.com/caid-technologies/opencad/blob/main/docs/CAID_ARTIFACT_CONTRACT.md Represents a patch payload for a CAID artifact. It includes schema version, artifact ID, source of the patch, and a list of parameter patches with old and new values and a reason. ```json { "schema_version": 1, "artifact_id": "simcorrect-problem1-forearm", "source": "simcorrect", "parameter_patches": [ { "name": "forearm_length", "old_value": 0.25, "value": 0.30, "reason": "sensitivity_analysis identified link2_length." } ] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.