Skip to main content

Independent, unified Python SDK for the MIDAS NX Open API (Civil NX + Gen NX)

Project description

midas-nx

An independent, unified Python SDK for the MIDAS NX Open API (MIDAS Civil NX + MIDAS Gen NX).

Unlike MIDASIT's official midas-civil / midas-gen packages — separate, near-duplicated codebases per product, covering roughly a third of the documented API surface — midas_nx is a single package for both products, built directly against the endpoint schema documented at Dennis5882/MIDAS-API. See ROADMAP.md for what's implemented so far vs. planned.

This is an unofficial, community project — not affiliated with or endorsed by MIDASIT.

Install

pip install -e ".[dev]"   # from a checkout, for development

Quick start

from midas_nx import MidasClient, Product
from midas_nx import doc
from midas_nx.db.project import Unit
from midas_nx.db.properties.material import Material
from midas_nx.db.properties.section import Section
from midas_nx.db.node_element import Node, Element

client = MidasClient(mapi_key="your-mapi-key-here", product=Product.GEN)

doc.new_project(client=client)

Unit.update({1: {"DIST": "M", "FORCE": "TONF"}}, client=client)

Material.create({1: {
    "TYPE": "CONC", "NAME": "C32",
    "PARAM": [{"P_TYPE": 1, "STANDARD": "AS17(RC)", "DB": "C32"}],
}}, client=client)

Section.create({1: {
    "SECTTYPE": "DBUSER", "SECT_NAME": "H300x150",
    "SECT_BEFORE": {
        "SHAPE": "H", "OFFSET_PT": "CC", "DATATYPE": 1,
        "SECT_I": {"DB_NAME": "KS21", "SECT_NAME": "H300x150x6.5/9"},
    },
}}, client=client)

Node.create({
    1: {"X": 0, "Y": 0, "Z": 0},
    2: {"X": 0, "Y": 0, "Z": 3.2},
}, client=client)

Element.create({1: {
    "TYPE": "BEAM", "MATL": 1, "SECT": 1, "NODE": [1, 2], "ANGLE": 0,
}}, client=client)

doc.save(client=client)

Or use the low-level free function directly (same calling convention as the MIDAS-API manual repo's examples):

from midas_nx import configure, MidasAPI

configure(mapi_key="your-mapi-key-here", product="gen")
MidasAPI("POST", "/doc/NEW", {"Argument": {}})

Design

  • Instance-based MidasClient — no global mutable state; errors raise typed exceptions (MidasAuthError, MidasNotFoundError, ...) instead of killing the process.
  • Unified Gen/CivilMidasClient(product=Product.GEN | Product.CIVIL); each resource class declares which product(s) it supports (PRODUCTS), and calling a Civil-only resource against a Gen client raises ProductMismatchError by default (strict_product=False to only warn).
  • /db/* resources are DbResource subclasses with .create()/.get()/.update()/.delete() classmethods; TypedDict payload types document each endpoint's schema (from docs/manual/*.md in the sibling repo) for editor/type-checker support, without runtime payload validation — schemas are too conditional (see e.g. the Eurocode moving-load endpoint, 5 mutually-exclusive variants) for a one-size-fits-all validated model.
  • /doc/* lifecycle endpoints are plain functions (doc.new_project(), doc.save(), ...) — not ID-keyed, wrapped in "Argument" rather than "Assign".

See docs/coverage.json / ROADMAP.md for the full endpoint list, what's implemented, and where new endpoints should go.

Testing

No live MIDAS Gen/Civil NX server is required — all tests mock HTTP via responses and assert request shape (URL, headers, JSON body) against what the manual documents.

pytest

Contributing

Pick an unimplemented endpoint from ROADMAP.md, follow the pattern in src/midas_nx/db/node_element.py (or doc.py for /doc/*//ope/*//view/*-style plain-function endpoints), and add a test mirroring tests/db/test_node_element.py. Mark it "implemented" in docs/coverage.json (see scripts/gen_roadmap.py) and regenerate ROADMAP.md.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

midas_nx-0.4.0.tar.gz (121.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

midas_nx-0.4.0-py3-none-any.whl (90.8 kB view details)

Uploaded Python 3

File details

Details for the file midas_nx-0.4.0.tar.gz.

File metadata

  • Download URL: midas_nx-0.4.0.tar.gz
  • Upload date:
  • Size: 121.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for midas_nx-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4b15a36fb2eea585a8cf59c12931f605121b645fc5b32a06a27e7f934ba74437
MD5 cc86855bd1029aee3734605d9049c00e
BLAKE2b-256 60692e9c00b4caaa771c846ebf888c7c0759960a3f47afa10b71fb937c611959

See more details on using hashes here.

Provenance

The following attestation bundles were made for midas_nx-0.4.0.tar.gz:

Publisher: publish.yml on Dennis5882/MIDAS-API-NX-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file midas_nx-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: midas_nx-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 90.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for midas_nx-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0d936bbd5bfdc78ba44103e43a51e00b26d1b974c19a392581f39053df047b2
MD5 17f3f224a8dd44b35823890af5a942da
BLAKE2b-256 942a70faeac693ef673eb1e407233fa3750f5a07e606c0ddfb2012ce6ae5c49c

See more details on using hashes here.

Provenance

The following attestation bundles were made for midas_nx-0.4.0-py3-none-any.whl:

Publisher: publish.yml on Dennis5882/MIDAS-API-NX-SDK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page