Metadata-Version: 2.5
Name: opencad2d
Version: 1.0.0
Summary: OpenCAD2D for Python: commands and scripts inside the OpenCAD2D app, driving it from outside, and its drawings without a window
Project-URL: Documentation, https://github.com/nguyenthanguth/opencad2d
Project-URL: Source, https://github.com/nguyenthanguth/opencad2d
License-Expression: MIT
License-File: LICENSE
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: <3.16,>=3.11
Requires-Dist: pythonnet<4,>=3.2.1
Provides-Extra: numpy
Requires-Dist: numpy>=1.26; extra == 'numpy'
Description-Content-Type: text/markdown

# opencad2d

GeometryHelper for Python: 2D and 3D geometry, DXF and DWG read and write, and the CAD presenter without a window
(a `CadDocument` edited through its command session and saved). The library is the .NET one, run on
[pythonnet](https://pythonnet.github.io/); the .NET names stay as they are, and the wheel carries stubs so an editor
(Pylance, pyright) completes them.

## Install

Windows, 64-bit, Python 3.11 to 3.15, and a .NET 8 (or later) runtime or .NET Framework 4.8:

```
pip install opencad2d[numpy]
```

The `numpy` extra is for `opencad2d.arrays`, which copies point arrays to and from numpy in one block.

## Example

```python
import opencad2d
from OpenCAD2D import CadCommandSession, CadDocument
from GeometryHelper.Dxf import DxfDatabase, DxfWriter

document = CadDocument.From(DxfDatabase.Parse(DxfWriter().ToString()))
session = CadCommandSession(document)
with opencad2d.undo_group(document, "A circle"):  # one undo step, or none if the block raises
    for line in ("CIRCLE", "0,0", "25"):
        session.Feed(line)
document.SaveAs("drawing.dwg")
print(document.EntityCount, opencad2d.__version__, opencad2d.runtime())
```

The runtime is chosen by the environment variable `OPENCAD2D_RUNTIME`: `auto` (the default: .NET 8 or later when
it is installed, else .NET Framework), `coreclr` or `netfx`.

The guide, with the runtime choice, the numpy helpers and the stubs, is at
<https://nguyenthanguth.github.io/GeometryHelper/>.
