mastapy


Namemastapy JSON
Version 15.0.0.post1 PyPI version JSON
download
home_pageNone
SummaryPython scripting API for MASTA.
upload_time2025-07-29 14:29:26
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.8
licenseNone
keywords masta mastapy smt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
<img src="https://documentation.smartmt.com/MastaAPI/15.0/images/smt_logo.png" width="150" alt="SMT"><br>
<img src="https://documentation.smartmt.com/MastaAPI/15.0/images/MASTA_15_logo.png" width="400" alt="Mastapy">
</h1><br>

[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![Python](https://img.shields.io/pypi/pyversions/mastapy
)

Mastapy is the Python scripting API for MASTA.

- **Website**: https://www.smartmt.com/
- **Support**: https://support.smartmt.com/
- **Documentation**: https://documentation.smartmt.com/MastaAPI/15.0/


### Features

- Powerful integration with MASTA with the ability to run Python scripts from the MASTA interface directly.
- Ability to use MASTA functionality external to the MASTA software in an independent script.
- An up-to-date and tight integration with Python. This is not a lightweight wrapper around the C# API. It is specifically designed for Python and works great in tandem with other common scientific Python packages (e.g. SciPy, NumPy, Pandas, Matplotlib, Seaborn, etc.)
- Extensive backwards compatibility support. Scripts written in older versions of mastapy will still work with new versions of MASTA.
- Full support for Linux and .NET 8.0 versions of the MASTA API.

### Release Information

#### Major Changes

- Importing local modules and packages is now fully supported by scripted properties.
- This package is now built using UV.
- Adds support for .NET 8.0 versions of the MASTA API.

#### Minor Changes

- Improved handling of invalidated (and read-only) properties.
- Improved exception handling. More exceptions are now exposed to users through the `mastapy.exceptions` module.
- Failed analyses are now reported to a user via an exception.
- Various improvements and bug fixes.

### Importing Local Modules or Packages in Scripted Properties

Previously, the expectation was scripted property code was contained within a single file. However, this could become unwieldy as the functionality of the scripted property grew. Refactoring code into separate modules and packages would be a natural progression and has always been supported, but any subsequent updates to that external code was not properly loaded into MASTA.

This update adds full support for that scenario. For example, take the following Python script, `scripted_property.py`, which contains a single scripted property. Note how it imports two separate modules from `my_package`.

```python
"""scripted_property.py"""

from mastapy import masta_property
from mastapy.system_model.part_model import RootAssembly

# Importing modules from a local package called "my_package"
from my_package import a
from my_package.sub_package import b


@masta_property("my_property")
def my_property(root_assembly: RootAssembly) -> None:
    ...
```

The following is the scripted properties directory in this scenario. `my_package` is defined right next to our `scripted_property.py` file, making it a locally imported package.

```
my_scripts/
├─ my_package/
│  ├─ sub_package/
│  │  ├─ b.py
│  │  ├─ __init__.py
│  ├─ __init__.py
│  ├─ a.py
├─ scripted_property.py
```

With this new update, any changes made to the files within `my_package` are detected by MASTA, without having to refresh the scripts. This makes it possible to share code between scripted properties in separate files and develop a more professional and reusable codebase.

### Improved Handling of Invalidated (and Read-Only) Properties

It is now easier to work with invalidated properties in your design. Several ways of handling them have been added.

The first option is to simply catch the exception:

```python
from mastapy.exceptions import InvalidatedPropertyException

try:
    value = design.material_agma
except InvalidatedPropertyException:
    # Do something
    ...
```

Or suppress it:

```python
import contextlib
from mastapy.exceptions import InvalidatedPropertyException

with contextlib.suppress(InvalidatedPropertyException):
    value = design.material_agma
```

Alternatively, you can check if a property is valid before accessing it by using `is_valid`. This method now accepts Pythonic snake_case names. `is_read_only` has been similarly updated.

```python
if design.is_valid("material_agma"):
    ...
```

Or use the `get_property` and `set_property` methods. In particular, `get_property` will return `None` if the property is invalidated, which makes it convenient to use with the walrus operator:

```python
if (value := design.get_property("material_agma")) is not None:
    ...
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mastapy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.8",
    "maintainer_email": null,
    "keywords": "masta, mastapy, smt",
    "author": null,
    "author_email": "George Baron <george.baron@smartmt.com>",
    "download_url": "https://files.pythonhosted.org/packages/fd/fd/48c2d4dae50a911dcaf4d4c4f4baecb7640e7916cf4d06b96bb27e253521/mastapy-15.0.0.post1.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n<img src=\"https://documentation.smartmt.com/MastaAPI/15.0/images/smt_logo.png\" width=\"150\" alt=\"SMT\"><br>\n<img src=\"https://documentation.smartmt.com/MastaAPI/15.0/images/MASTA_15_logo.png\" width=\"400\" alt=\"Mastapy\">\n</h1><br>\n\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![Python](https://img.shields.io/pypi/pyversions/mastapy\n)\n\nMastapy is the Python scripting API for MASTA.\n\n- **Website**: https://www.smartmt.com/\n- **Support**: https://support.smartmt.com/\n- **Documentation**: https://documentation.smartmt.com/MastaAPI/15.0/\n\n\n### Features\n\n- Powerful integration with MASTA with the ability to run Python scripts from the MASTA interface directly.\n- Ability to use MASTA functionality external to the MASTA software in an independent script.\n- An up-to-date and tight integration with Python. This is not a lightweight wrapper around the C# API. It is specifically designed for Python and works great in tandem with other common scientific Python packages (e.g. SciPy, NumPy, Pandas, Matplotlib, Seaborn, etc.)\n- Extensive backwards compatibility support. Scripts written in older versions of mastapy will still work with new versions of MASTA.\n- Full support for Linux and .NET 8.0 versions of the MASTA API.\n\n### Release Information\n\n#### Major Changes\n\n- Importing local modules and packages is now fully supported by scripted properties.\n- This package is now built using UV.\n- Adds support for .NET 8.0 versions of the MASTA API.\n\n#### Minor Changes\n\n- Improved handling of invalidated (and read-only) properties.\n- Improved exception handling. More exceptions are now exposed to users through the `mastapy.exceptions` module.\n- Failed analyses are now reported to a user via an exception.\n- Various improvements and bug fixes.\n\n### Importing Local Modules or Packages in Scripted Properties\n\nPreviously, the expectation was scripted property code was contained within a single file. However, this could become unwieldy as the functionality of the scripted property grew. Refactoring code into separate modules and packages would be a natural progression and has always been supported, but any subsequent updates to that external code was not properly loaded into MASTA.\n\nThis update adds full support for that scenario. For example, take the following Python script, `scripted_property.py`, which contains a single scripted property. Note how it imports two separate modules from `my_package`.\n\n```python\n\"\"\"scripted_property.py\"\"\"\n\nfrom mastapy import masta_property\nfrom mastapy.system_model.part_model import RootAssembly\n\n# Importing modules from a local package called \"my_package\"\nfrom my_package import a\nfrom my_package.sub_package import b\n\n\n@masta_property(\"my_property\")\ndef my_property(root_assembly: RootAssembly) -> None:\n    ...\n```\n\nThe following is the scripted properties directory in this scenario. `my_package` is defined right next to our `scripted_property.py` file, making it a locally imported package.\n\n```\nmy_scripts/\n\u251c\u2500 my_package/\n\u2502  \u251c\u2500 sub_package/\n\u2502  \u2502  \u251c\u2500 b.py\n\u2502  \u2502  \u251c\u2500 __init__.py\n\u2502  \u251c\u2500 __init__.py\n\u2502  \u251c\u2500 a.py\n\u251c\u2500 scripted_property.py\n```\n\nWith this new update, any changes made to the files within `my_package` are detected by MASTA, without having to refresh the scripts. This makes it possible to share code between scripted properties in separate files and develop a more professional and reusable codebase.\n\n### Improved Handling of Invalidated (and Read-Only) Properties\n\nIt is now easier to work with invalidated properties in your design. Several ways of handling them have been added.\n\nThe first option is to simply catch the exception:\n\n```python\nfrom mastapy.exceptions import InvalidatedPropertyException\n\ntry:\n    value = design.material_agma\nexcept InvalidatedPropertyException:\n    # Do something\n    ...\n```\n\nOr suppress it:\n\n```python\nimport contextlib\nfrom mastapy.exceptions import InvalidatedPropertyException\n\nwith contextlib.suppress(InvalidatedPropertyException):\n    value = design.material_agma\n```\n\nAlternatively, you can check if a property is valid before accessing it by using `is_valid`. This method now accepts Pythonic snake_case names. `is_read_only` has been similarly updated.\n\n```python\nif design.is_valid(\"material_agma\"):\n    ...\n```\n\nOr use the `get_property` and `set_property` methods. In particular, `get_property` will return `None` if the property is invalidated, which makes it convenient to use with the walrus operator:\n\n```python\nif (value := design.get_property(\"material_agma\")) is not None:\n    ...\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python scripting API for MASTA.",
    "version": "15.0.0.post1",
    "project_urls": {
        "Homepage": "https://www.smartmt.com/",
        "documentation": "https://documentation.smartmt.com/MastaAPI/15.0/"
    },
    "split_keywords": [
        "masta",
        " mastapy",
        " smt"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "24fdfe9d6c2417ed3805813a2e45a7e82175c24f3baf4de1109bdb59ccba747a",
                "md5": "475275adea005099a12fb5d26b7b55a0",
                "sha256": "752c502949c0c3d593570cd9f2c5900d961bc10f160d950dcbfb128c997af1eb"
            },
            "downloads": -1,
            "filename": "mastapy-15.0.0.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "475275adea005099a12fb5d26b7b55a0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.8",
            "size": 16033271,
            "upload_time": "2025-07-29T14:29:30",
            "upload_time_iso_8601": "2025-07-29T14:29:30.110414Z",
            "url": "https://files.pythonhosted.org/packages/24/fd/fe9d6c2417ed3805813a2e45a7e82175c24f3baf4de1109bdb59ccba747a/mastapy-15.0.0.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fdfd48c2d4dae50a911dcaf4d4c4f4baecb7640e7916cf4d06b96bb27e253521",
                "md5": "39acc5c8d2c17cdc0143961f509dec55",
                "sha256": "caae2cdda5771c3103468e24ecfbc8851885de23e2460d41683e350ab68190dc"
            },
            "downloads": -1,
            "filename": "mastapy-15.0.0.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "39acc5c8d2c17cdc0143961f509dec55",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.8",
            "size": 5103738,
            "upload_time": "2025-07-29T14:29:26",
            "upload_time_iso_8601": "2025-07-29T14:29:26.061043Z",
            "url": "https://files.pythonhosted.org/packages/fd/fd/48c2d4dae50a911dcaf4d4c4f4baecb7640e7916cf4d06b96bb27e253521/mastapy-15.0.0.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-29 14:29:26",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "mastapy"
}
        
Elapsed time: 1.53361s