ai-zemax-optical-design
Automated optical design agent skill for Ansys Zemax OpticStudio via ZOS-API — AI-driven requirements parsing, lens modeling, staged optimization, and design reporting.
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Badge for your README
Markdown
[](/listings/jerry-del975--ai-zemax-optical-design)HTML
<a href="/listings/jerry-del975--ai-zemax-optical-design"><img src="/api/listings/jerry-del975--ai-zemax-optical-design/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
# Clone the repo git clone https://github.com/Jerry-del975/ai-zemax-optical-design.git cd ai-zemax-optical-design # Install Python dependencies pip install zospy pythonnet # Install as Claude Code skill (default) npm install # Or install as Codex skill npm run install:codex
The postinstall script deploys the skill to `~/.claude/skills/ai-zemax-optical-design/` by default. To install for Codex, run `npm run install:codex`; this deploys to `${CODEX_HOME:-~/.codex}/skills/ai-zemax-optical-design/`. Restart the target agent after installation.
Prerequisites
| Component | Requirement | |-----------|-------------| | **OS** | Windows 10/11 | | **OpticStudio** | 2024 R1 (tested), v20.3+ (via ZOSPy) | | **Python** | 3.10+ | | **Python packages** | `zospy>=2.1` (primary connection, multi-version auto-discovery), `pythonnet` (underlying .NET bridge, also used as fallback when ZOSPy is unavailable) | | **Claude Code or Codex** | latest |
---
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
SKILL.md · Manifest · 163 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- ---
- name: ai-zemax-optical-design
- description: "Automated optical design agent for Ansys Zemax OpticStudio 2024 R1 through ZOS-API. Use when Codex should automatically turn optical requirements or an existing .zmx/.zos/.zar file into an executable Zemax design loop: parse requirements, create or load a lens model, run baseline analyses, choose variables and constraints, build a merit function, run staged optimization, compare iterations, save final lens files, and produce machine-readable design logs. Supports both prime lenses and multi-configuration zoom systems."
- ---
- # AI Zemax Optical Design
- Use this skill as an automation agent for Zemax optical design. The deliverable is executable ZOS-API automation, not only design advice.
- Target environment: Ansys Zemax OpticStudio v20.3+, with ZOSPy handling version discovery and API connection.
- ## Operating Contract
- Always drive toward these artifacts:
- - A normalized requirements JSON with explicit assumptions.
- - A seed-design selection record when an official or catalog case can shorten the path to a valid design.
- - A runnable ZOS-API Python script or patched scaffold.
- - Baseline analysis exports before optimization.
- - A staged variable/constraint/merit-function plan.
- - Versioned lens saves for accepted stages.
- - A final design log with metrics, constraints, changes, and unresolved risks.
- Do not stop at conceptual optical-design suggestions unless the user explicitly asks only for theory.
- For complex lens families, treat the existing multi-round scoring / optimization scaffold as stable infrastructure and do not rewrite it in this pass.
- ## Hard Constraints
- - Do not invent a starting architecture when a closer official or catalog seed is available.
- - Do not silently switch from a seed-based workflow to a from-scratch workflow.
- - Do not broaden the problem scope beyond the user's requested lens class, focal-length range, aperture, and packaging limits.
- - Do not treat a weakly similar seed as acceptable unless the mismatch is explicitly logged.
- - Do not begin optimization until the seed selection, target normalization, and structural gap list are complete.
- - Do not claim a design is suitable for the target if the seed-to-target gap is still unaccounted for.
- - Do not fill missing structural details with guesses; record them as assumptions or ask for user confirmation.
- - Do not modify the user's requested class of lens to make the problem easier.
- - Do not replace the staged optimization logic; preserve the existing feasibility -> image quality -> field balance -> manufacturability flow unless the user explicitly requests a different strategy.
- ## Complex-Design Guardrails
- - Use a conservative interpretation for difficult lenses: prioritize structural fidelity, convergence stability, and traceable changes over aggressive optimization.
- - Treat large family mismatches as blocking until the structural gap is explained and logged.
- - Prefer the nearest seed that matches the requested optical family, zoom behavior, aperture regime, and packaging constraints, even if the focal length is imperfect.
- - If the best available seed is only a partial match, log the exact mismatch and the adaptation burden before proceeding.
- - For difficult designs, do not expand degrees of freedom just to force convergence; increase them only when the current stage and gap analysis justify it.
- ## Automation Flow
- 1. Parse input.
- - Normalize requirements with `references/requirements-schema.md`.
- - If an existing `.zmx`, `.zos`, or `.zar` is provided, load it first and extract baseline fields, wavelengths, aperture, configurations, prescription, and merit state.
- - Mark assumptions in the log instead of silently inventing constraints, and include seed provenance for any adopted starting design.
- - For new designs, search first for the closest official Zemax example or catalog/reference lens with the same structural family, then adapt from that seed instead of starting from a blank system.
- - For fast zoom imaging tasks such as an F/1.4, 3x zoom, 18-55 mm-style lens, prefer a structurally similar zoom seed and record the match criteria.
- - If no clearly relevant seed is available, stop and report the missing structural basis instead of improvising a new architecture.
- - Record the structural gap list before any optimization so the adaptation burden is explicit.
- 2. Create or load the Zemax model.
- - Prefer loading an existing model when provided.
- - For new designs, choose the best seed design first, then adapt it to the requested focal-length range, aperture, field, and packaging limits.
- - When no suitable seed exists, create a minimal sequential starting model from first-order requirements, then set surfaces, aperture, fields, wavelengths, stop, image plane, and materials.
- - For zoom designs, set multi-configuration data before optimization.
- - Keep the seed architecture stable during the initial adaptation stage; do not add, remove, or reorder groups without logging the reason.
- 3. Run baseline evaluation.
- - Export first-order data, prescription, spot, FFT MTF, wavefront, ray fan, and field curvature/distortion.
- - Add domain-specific analyses when relevant.
- - Parse raw analysis text into metrics JSON where practical.
- 4. Select variables and constraints.
- - Choose variables in stages: focus/air gaps, curvatures, thicknesses, glass substitutions, aspheres, multi-configuration solves, tolerance compensators.
- - Encode hard feasibility constraints before image quality goals.
- - Only vary parameters that preserve the current structural intent unless the user explicitly approves a structural change.
- 5. Build and run the merit function.
- - Use `references/merit-function.md`.
- - Run staged optimization: feasibility, image quality, field balance, manufacturability, optional tolerance readiness.
- - Save lens and metrics after each stage.
- - If a stage fails, fix the failure at the current stage rather than jumping ahead to a later one.
- 6. Compare and accept iterations.
- - Compare each candidate against baseline, previous accepted design, and user targets.
- - Reject candidates that improve one score by creating hidden geometry, glass, aperture, field, or tolerance failures.
- - Preserve seed-design provenance so the final log explains how the result diverged from the starting case.
- - Reject any candidate that changes the lens class, zoom behavior, or complexity envelope without explicit user approval.
- - Log any new assumption introduced during optimization immediately, with the reason it was needed.
- 7. Report outputs.
- - Return final lens path, intermediate lens paths, analysis output paths, design log path, performance versus targets, assumptions, and manual checks still needed.
- ## Scripts
- - `scripts/automated_design_agent.py`: controller for the automated prime-lens design loop.
- - `scripts/zoom_lens_design_agent.py`: controller for multi-configuration zoom lens design with MCE setup, variable air gaps, and per-configuration optimization.
- - `scripts/zos_design_primitives.py`: ZOS-API connection (pythonnet with ZOSPy fallback), analysis export, save, metrics, and optimization primitives. Supports OpticStudio 2024 R1+.
- - `scripts/connection_smoke_test.py`: quick connection test for Standalone or Interactive Extension.
- - `scripts/connection_smoke_test.ps1`: PowerShell smoke test that loads the OpticStudio DLLs directly when Python lacks `pythonnet`.
- - `scripts/design_single_lens_interactive.ps1`: live Interactive Extension smoke design that creates a simple N-BK7 singlet, saves lens files, and exports analyses.
- - `examples/minimal_imaging_requirements.json`: small sample input for smoke-testing the automated design controller.
- - `examples/apsc_18-55_f1.4_zoom_requirements.json`: APS-C 18-55mm F/1.4 3× zoom lens requirements with three zoom configurations (wide/mid/tele).
- ## References
- - `references/requirements-schema.md`: normalized input schema.
- - `references/merit-function.md`: staged merit-function and variable-selection rules.
- - `references/result-parsing.md`: analysis export, parsing, comparison, and logging rules.
- - `references/zos-api-patterns.md`: OpticStudio 2024 R1 ZOS-API reminders.
- Load only the reference files needed for the active task.
- ## Seed-Design Policy
- For complex optical structures, especially zoom lenses, the default strategy is:
- 1. Find the closest official Zemax example or a catalog/reference lens in the same structural family.
- 2. Compare candidate seeds against the request on these axes:
- - focal-length span
- - aperture and entrance pupil behavior
- - number of groups and elements
- - zoom mechanism and conjugate behavior
- - field of view and image format
- - package length and back focal space
- - glass strategy and asphere usage
- 3. Pick the best structural match as the seed design and log the gaps explicitly.
- 4. Adapt the seed in small stages instead of redrawing the system from scratch.
- 5. Keep seed provenance, mismatch notes, and any manual structural edits visible in the final design log.
- For a fast 3x zoom 18-55 mm lens at F/1.4, bias toward the nearest zoom imaging seed even if it is not an exact focal-length match.
- ## Connection Diagnostics
- For Python automation, **pythonnet** (`pip install pythonnet`) is required. ZOSPy (`pip install zospy`) is also supported as an alternative connection layer.
- Default to Interactive Extension for live testing because Standalone may crash or hang
- when the API license/session is unhealthy. Use Standalone only when explicitly requested
- or after the smoke test passes.
- Expected healthy connection:
- - Standalone: `CreateNewApplication()` returns an application, `IsValidLicenseForAPI=True`, and `PrimarySystem` is not null.
- - Interactive Extension: OpticStudio must be open in an extension-ready state; `ConnectAsExtension(0)` must return an application with valid API license and primary system.
- If a connection object exists but `IsValidLicenseForAPI=False` or `PrimarySystem` is null,
- treat it as not usable for automation and fix the OpticStudio extension/license state before
- running the design loop.
- Do not retry Standalone repeatedly after an OpticStudio exception dialog or timeout.
- Clear the dialog, restart OpticStudio if needed, then validate Interactive Extension first with:
- ```powershell
- powershell -ExecutionPolicy Bypass -File .\scripts\connection_smoke_test.ps1
- ```
- ### ZOS-API Quirks (2024 R1)
- - `system.LDE.StopSurface = N` — set stop by property, not `MakeSurfaceStop()`.
- - `system.MFE` — access merit function editor directly, not via `Tools.OpenMeritFunction()`.
- - MCE: `AddConfiguration(True)` — takes bool, not int.
- - MCE: `ChangeType(MultiConfigOperandType.THIC)` — use enum, not string.
- - Optimization wizard: `wizard.OK()` not `Ok()`. Properties: `Ring`, `Arm`, `Data` (singular).
- - Python.NET 3.0: cannot assign `int` to enum properties (e.g. `tool.Cycles`).
- - `SaveAs()` requires absolute paths; relative paths may fail with non-ASCII directories.
README.md · README · 303 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- # AI Zemax Optical Design
- Automated optical design skill for **Claude Code and Codex** — drives **Ansys Zemax OpticStudio** through ZOS-API to turn optical requirements into executable, multi-stage design loops.
- [](https://github.com/Jerry-del975/ai-zemax-optical-design)
- [](LICENSE)
- ---
- ## What's New in v1.3.0
- - **Profile-driven zoom lens design** — `zoom_lens_design_agent.py` is no longer hardcoded to APS-C 18-55mm. The complete starting prescription (surfaces, materials, variable gaps, MCE setup, optimization variables per stage) is defined in a standalone JSON profile. Swap profiles to design different zoom systems without touching Python code.
- - **Zoom lens profile schema** — new `lens_profile` field in requirements references a JSON profile file or inline object. Profiles define every surface, variable gap, glass material, stop location, merit function parameters, and per-stage variable release lists. See `examples/profiles/apsc_18_55_f14_zoom_profile.json` for the first example and `references/requirements-schema.md` for the schema.
- - **Per-configuration gap initialization** — `resolve_gap_initial_value()` supports three priority levels: explicit `gap_values_mm` in each zoom configuration → per-config name matching in `variable_gaps.per_config` → `default_mm` fallback. No more array-index-based gap lookup.
- - **Surgical variable control** — each optimization stage uses profile-defined surface lists (`feasibility_radius_surfaces`, `image-quality_radius_surfaces`, `material_surfaces`, etc.) instead of varying every surface. This prevents over-parameterization and accelerates convergence.
- - **`InstanceId` parameterization** — PowerShell connection scripts now accept `-InstanceId` (default 1) instead of hardcoded `ConnectAsExtension(0)`.
- - **pythonnet fallback singlet script** — new `scripts/design_single_lens_pythonnet.py` is a lightweight alternative that connects directly via `clr` / pythonnet without ZOSPy. Intended as a fallback for environments where ZOSPy cannot be installed; the primary connection layer for all design agents remains ZOSPy.
- - **Zoom lens profile unit tests** — `tests/test_zoom_lens_profile.py` validates profile loading from path, prescription building with stop surfaces, and gap initialization priority logic.
- ## What's New in v1.2.0
- - **Zoom lens design agent** — new `scripts/zoom_lens_design_agent.py` for multi-configuration zoom systems with automatic MCE setup, staged optimization, and per-configuration analysis export.
- - **APS-C 18-55mm F/1.4 example** — complete zoom requirements and 4-group starting prescription with 3× zoom ratio, constant F/1.4 aperture.
- - **Hardened ZOS-API patterns** — fixed real-world API mismatches discovered during intensive testing: `MultiConfigOperandType` enum usage, MCE `AddConfiguration` signatures, optimization wizard property names, `LDE.StopSurface`, Python.NET 3.0 enum handling, and more.
- - **Automated analysis export** — per-configuration spot, MTF, wavefront, ray fan, and distortion analyses for every stage.
- - **Extended merit function builder** — built-in optimization wizard integration plus first-order targets (EFFL, WFNO, REAY, AXCL, LACL, DIMX) and manufacturing constraints (MNCT, MNET, MNEA, MXSD, MNEG, GCOS).
- ## What's New in v1.1.0
- - **ZOSPy integration** — connection layer uses [ZOSPy](https://github.com/MREYE-LUMC/ZOSPy) for automatic version discovery across OpticStudio v20.3 through v26+. A standalone pythonnet fallback script is also available for environments where ZOSPy cannot be installed.
- - **Multi-version support** — OpticStudio v20.3 through v26+.
- - **Dual-mode connection** — Interactive Extension (recommended) and Standalone.
- ---
- ## Installation
- ```bash
- # Clone the repo
- git clone https://github.com/Jerry-del975/ai-zemax-optical-design.git
- cd ai-zemax-optical-design
- # Install Python dependencies
- pip install zospy pythonnet
- # Install as Claude Code skill (default)
- npm install
- # Or install as Codex skill
- npm run install:codex
- ```
- The postinstall script deploys the skill to `~/.claude/skills/ai-zemax-optical-design/` by default. To install for Codex, run `npm run install:codex`; this deploys to `${CODEX_HOME:-~/.codex}/skills/ai-zemax-optical-design/`. Restart the target agent after installation.
- ### Prerequisites
- | Component | Requirement |
- |-----------|-------------|
- | **OS** | Windows 10/11 |
- | **OpticStudio** | 2024 R1 (tested), v20.3+ (via ZOSPy) |
- | **Python** | 3.10+ |
- | **Python packages** | `zospy>=2.1` (primary connection, multi-version auto-discovery), `pythonnet` (underlying .NET bridge, also used as fallback when ZOSPy is unavailable) |
- | **Claude Code or Codex** | latest |
- ---
- ## Quickstart
- ### 1. Smoke test connection
- Make sure OpticStudio is open, then:
- ```bash
- python scripts/connection_smoke_test.py
- # Expected: "Connected: yes"
- ```
- ### 2. Design a lens
- **Simple prime lens:**
- ```bash
- python scripts/automated_design_agent.py \
- --requirements examples/minimal_imaging_requirements.json \
- --out output/my-design
- ```
- **Zoom lens (APS-C 18-55mm F/1.4):**
- ```bash
- python scripts/zoom_lens_design_agent.py \
- --requirements examples/apsc_18-55_f1.4_zoom_requirements.json \
- --out output/aps-c-zoom
- ```
- **Custom zoom lens (your own profile):**
- ```bash
- # 1. Create a profile JSON (copy examples/profiles/ as starting point)
- # 2. Point requirements.lens_profile to your profile
- python scripts/zoom_lens_design_agent.py \
- --requirements my_zoom_requirements.json \
- --out output/my-zoom-design
- ```
- ### 3. Review results
- ```
- output/aps-c-zoom/
- ├── zoom_baseline.zmx ← Baseline lens (before optimization)
- ├── zoom_feasibility.zmx ← After feasibility stage
- ├── zoom_image-quality.zmx ← After image quality optimization
- ├── zoom_field-balance.zmx ← After field balancing
- ├── zoom_manufacturability.zmx ← Final lens (all stages)
- ├── design-log.jsonl ← Machine-readable event log
- ├── metrics-*.json ← Per-stage merit values
- ├── requirements.json ← Normalized requirements (copy)
- └── analyses/
- ├── baseline/ ← 5 analyses × 3 configurations
- ├── feasibility/
- ├── image-quality/
- ├── field-balance/
- └── manufacturability/
- ```
- ---
- ## What It Does
- This skill turns Claude Code or Codex into a Zemax automation agent:
- 1. **Parse requirements** — normalize optical specs from JSON or existing `.zmx` / `.zos` / `.zar` files
- 2. **Build or load models** — create sequential starting prescriptions (prime or zoom), or adapt existing designs
- 3. **Setup multi-configuration** — automatic MCE operand setup for zoom systems with variable air gaps
- 4. **Run baseline analyses** — spot diagrams, FFT MTF, wavefront maps, ray fans, field curvature/distortion
- 5. **Stage optimization** — feasibility → image quality → field balance → manufacturability
- 6. **Export everything** — versioned lens files, analysis text exports, metrics JSON, and design logs
- ---
- ## Project Structure
- ```
- ├── SKILL.md # Skill definition (loaded by Claude Code or Codex)
- ├── README.md
- ├── package.json
- ├── install.js # Installer: deploys skill to ~/.claude/skills/ or ~/.codex/skills/
- │
- ├── scripts/
- │ ├── zos_design_primitives.py # Core: ZOSPy connection, analysis, optimization, save
- │ ├── automated_design_agent.py # Prime lens design controller (ZOSPy)
- │ ├── zoom_lens_design_agent.py # ★ Profile-driven zoom design controller (ZOSPy)
- │ ├── design_single_lens_pythonnet.py # ★ Lightweight pythonnet fallback singlet (no ZOSPy)
- │ ├── connection_smoke_test.ps1 # PowerShell ZOS-API health check
- │ ├── connection_smoke_test.py # Python ZOS-API health check (ZOSPy)
- │ └── design_single_lens_interactive.ps1
- │
- ├── references/
- │ ├── requirements-schema.md # Normalized input schema
- │ ├── merit-function.md # Staged merit-function rules
- │ ├── result-parsing.md # Analysis export & logging rules
- │ └── zos-api-patterns.md # ZOS-API 2024 R1 reference
- │
- ├── examples/
- │ ├── profiles/
- │ │ └── apsc_18_55_f14_zoom_profile.json # ★ APS-C 4-group zoom profile (new)
- │ ├── minimal_imaging_requirements.json
- │ ├── apsc_18-55_f1.4_zoom_requirements.json
- │ └── seeded_complex_zoom_requirements.json
- │
- ├── tests/
- │ ├── test_zos_design_primitives.py
- │ ├── test_automated_design_agent.py
- │ ├── test_requirements_schema.py
- │ └── test_zoom_lens_profile.py # ★ Profile loading & gap init tests (new)
- │
- └── output/ # ★ Design outputs (gitignored)
- ```
- ---
- ## Supported Design Types
- | Type | Agent | Connection | Features |
- |------|-------|------------|----------|
- | Prime lens | `automated_design_agent.py` | ZOSPy (default) | Single-config, EFFL/BFL/F# targets |
- | Zoom lens | `zoom_lens_design_agent.py` | ZOSPy (default) | JSON profile-driven, MCE multi-config, variable air gaps, per-config EFL |
- | Seed-based | `automated_design_agent.py` | ZOSPy (default) | Load `.zmx` as starting point, adapt to targets |
- | Singlet (fallback) | `design_single_lens_pythonnet.py` | pythonnet direct | No ZOSPy dependency; lightweight verification |
- ---
- ## Optimization Stages
- | Stage | What It Does | Variables |
- |-------|-------------|-----------|
- | **Baseline** | Export analyses without optimization | None |
- | **Feasibility** | Hit EFL, F/#, BFL, image height targets | MCE gaps, BFL, profile-defined feasibility radii |
- | **Image Quality** | Minimize RMS spot, wavefront, chromatic error | Profile-defined radii + thicknesses |
- | **Field Balance** | Equalize performance across fields/configs | Full profile-defined radii + thicknesses |
- | **Manufacturability** | Enforce edge thickness, glass constraints | Profile-defined radii + thicknesses + glass substitutions |
- ---
- ## Zoom Lens Profile System (v1.3)
- The zoom agent is now fully profile-driven. Instead of a hardcoded prescription, swap a JSON file to design any zoom lens.
- ```json
- {
- "name": "my zoom profile",
- "image_surface": 12,
- "surfaces": [
- {"surface": 1, "radius": 60.0, "thickness": 5.0, "material": "N-BK7"},
- {"surface": 2, "radius": -80.0, "thickness": 8.0, "material": "", "variable_gap": "g1"},
- {"surface": 5, "radius": 55.0, "thickness": 4.0, "material": "N-BK7", "stop": true}
- ],
- "variable_gaps": [
- {"name": "g1", "surface": 2, "default_mm": 8.0, "per_config": {"wide": 6.0, "tele": 14.0}}
- ],
- "merit": {"bfl_surface": 11, "max_field_index": 3},
- "variables": {
- "feasibility_radius_surfaces": [1, 3, 5],
- "image-quality_radius_surfaces": [1, 2, 3, 4, 5],
- "image-quality_thickness_surfaces": [2, 4, 7],
- "material_surfaces": [1, 3, 5]
- }
- }
- ```
- Key profile fields:
- | Section | Purpose |
- |---------|---------|
- | `surfaces` | Complete prescription — radius, thickness, material, stop flag, group label, `variable_gap` tag |
- | `variable_gaps` | Which gaps vary with zoom position, default values, and per-configuration overrides |
- | `merit` | BFL surface reference and max field index for merit function construction |
- | `mce` | Multi-Configuration Editor settings (aperture/field operand inclusion) |
- | `variables` | Per-stage surface lists controlling exactly which radii, thicknesses, and materials are released |
- Each zoom configuration can override initial gap values via `gap_values_mm` or `per_config` name matching. See `examples/profiles/apsc_18_55_f14_zoom_profile.json` for a complete 4-group 24-surface example.
- ---
- ## Connection
- ### Default: ZOSPy (multi-version auto-discovery)
- All design agents use ZOSPy as the primary connection layer. ZOSPy automatically discovers your OpticStudio installation (v20.3 through v26+), loads the correct ZOSAPI DLLs, and returns a ready-to-use application object. No hardcoded paths, no version-specific configuration.
- ```python
- from zos_design_primitives import connect_zemax
- # Interactive Extension (OpticStudio must be open — recommended)
- app = connect_zemax(standalone=False)
- # Standalone (creates new OpticStudio instance)
- app = connect_zemax(standalone=True)
- system = app.PrimarySystem
- ```
- ### Fallback: pythonnet direct connection
- When ZOSPy cannot be installed (air-gapped environments, dependency conflicts), `design_single_lens_pythonnet.py` provides a lightweight fallback that loads the ZOSAPI DLLs directly via `clr.AddReference`. This requires manually specifying the OpticStudio install path via `--zos-root` and only supports a single version at a time.
- ```bash
- python scripts/design_single_lens_pythonnet.py \
- --zos-root "D:\Program Files\Ansys Zemax OpticStudio 2024 R1.00" \
- --out output/singlet
- ```
- The two main design agents (`automated_design_agent.py` and `zoom_lens_design_agent.py`) **always use ZOSPy** — there is no scenario where they silently fall back to pythonnet. The pythonnet path exists only in the standalone singlet script for environments that explicitly choose it.
- ---
- ## Known Limitations
- - **MCE operand API** — Python.NET 3.0 has limited enum-to-int conversion; MCE operand types must use `MultiConfigOperandType` enum values explicitly.
- - **Chinese paths** — OpticStudio `SaveAs` requires absolute paths; relative paths may silently fail with non-ASCII directory names.
- - **Optimization wizard** — properties use `OK()` (uppercase), `Ring`/`Arm`/`Data` (singular), `PupilIntegrationMethod` (full name) — not the intuitive names.
- - **Merit function access** — use `system.MFE` directly, not `system.Tools.OpenMeritFunction()`.
- - **Stop surface** — set via `system.LDE.StopSurface = N`, not `MakeSurfaceStop()`.
- ---
- ## Upgrading
- ```bash
- # Remove old Claude Code skill
- rm -rf ~/.claude/skills/ai-zemax-optical-design
- # Or remove old Codex skill
- rm -rf ~/.codex/skills/ai-zemax-optical-design
- # Pull latest
- cd ai-zemax-optical-design
- git pull origin master
- npm install
- ```
- ---
- ## License
- MIT © [Jerry](https://github.com/Jerry-del975)
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.