openscad-runner


Nameopenscad-runner JSON
Version 1.1.1 PyPI version JSON
download
home_page
SummaryA Python library to interface with the OpenSCAD app.
upload_time2024-01-26 06:38:12
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords openscad interface
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            OpenSCAD Runner
===============

A Python library to interface with and run the OpenSCAD interpreter.

ColorScheme Enum Class
----------------------
``ColorScheme`` defines the following enums:
    - cornfield
    - metallic
    - sunset
    - starnight
    - beforedawn
    - nature
    - deepocean
    - solarized
    - tomorrow
    - tomorrow_night
    - monotone

RenderMode Enum Class
----------------------
``RenderMode`` defines the following enums::
    - test_only
    - render
    - preview
    - thrown_together
    - wireframe

OpenScadRunner Class
---------------------
The ``OpenScadRunner`` class provides the following methods:

- ``__init__()`` The initializer method, which has the following arguments:
    - scriptfile = The name of the script file to process.
    - outfile = The name of the file to output to.
    - imgsize = The size of the imagefile to output to, if outputting to a PNG or GIF.  Default: (640,480)
    - antialias = The antialiasing scaling factor.  If greater than 1.0, images are generated at a larger size, then scaled down to the target size with anti-aliasing.  Default: 1.0  (no anti-aliasing)
    - animate = If given an integer number of frames, creates that many frames of animation, and collates them into an animated GIF or APNG.  Default: None
    - animate_duration = Number of milliseconds per frame for an animated GIF or APNG.  Default: 250
    - render_mode = The rendering mode to use when generating an image.  See RenderMode Enum.  Default: RenderMode.preview
    - show_axes = If True, show axes in the rendering.  Default: True
    - show_scales = If True, show the scales along the axes.  Default: True
    - show_edges = If True, shows the edges of all the faces.  Default: False
    - show_crosshairs = If True, shows the crosshairs for the center of the camera translation.  Default: False
    - camera = Gives the camera position as either [translate_x,y,z,rot_x,y,z,dist] or [eye_x,y,z,center_x,y,z]
    - orthographic = If True, render orthographic.  If False, render with perspective.  Default: False
    - auto_center = If True, and script does not set $vpt, $vpr, or $vpd, then centers the shape in the rendered image.  Default: False
    - view_all = If True, and script does not set $vpd, then the field of view is scaled to show the complete rendered shape.  Default: False
    - color_scheme = The color scheme to render an image with.  See ColorScheme Enum.  Default: ColorScheme.cornfield,
    - csg_limit = If given, the maximum number of CSG elements to render.
    - deps_file = If given, the file to write Makefile dependancies out to.
    - make_file = If given, the Makefile script to run when missing a dependency.
    - set_vars = An optional dictionary of script variables and values to set.
    - customizer_file = If given, specifies the file containing Customizer Parameters.
    - customizer_params = An optional dictionary of customizer parameter names and values to set.
    - hard_warnings = Stop at first WARNING, as if it were an ERROR.  Default: False
    - quiet = Suppresses non-error, non-warning messages.  Default: False
- ``good()`` Returns True if the ``run()`` method was called, and processing completed successfully.
- ``__bool__()`` Returns True if the ``run()`` method was called, and processing completed, whether or not it was successful.
- ``run()`` Run the OpenSCAD app with the current settings.  This sets some instance variables:
    - .complete = A boolean value indicating if the processing has completed yet.
    - .success = A boolean value indicating if the processing completed sucessfully.
    - .script = The script that was evaluated, as a list of line strings.
    - .cmdline = The commandline arguments used to launch the OpenSCAD app.
    - .return_code = The return code from OpenSCAD.  Generally 0 if successful.
    - .echos = A list of ECHO: output line strings.
    - .warnings = A list of WARNING: output line strings.
    - .errors = A list of ERROR: or TRACE: output line strings.


Creating an STL file::

    from openscad_runner import OpenScadRunner
    osr = OpenScadRunner("example.scad", "example.stl")
    osr.run()
    for line in osr.echos:
        print(line)
    for line in osr.warnings:
        print(line)
    for line in osr.errors:
        print(line)
    if osr.good():
        print("Successfully created example.stl")

Creating a Preview PNG::

    from openscad_runner import RenderMode, OpenScadRunner
    osr = OpenScadRunner("example.scad", "example.png", render_mode=RenderMode.preview, imgsize=(800,600), antialias=2.0)
    osr.run()
    for line in osr.echos:
        print(line)
    for line in osr.warnings:
        print(line)
    for line in osr.errors:
        print(line)
    if osr.good():
        print("Successfully created example.png")

Creating a Fully Rendered PNG::

    from openscad_runner import RenderMode, OpenScadRunner
    osr = OpenScadRunner("example.scad", "example.png", render_mode=RenderMode.render, imgsize=(800,600), antialias=2.0)
    osr.run()
    for line in osr.echos:
        print(line)
    for line in osr.warnings:
        print(line)
    for line in osr.errors:
        print(line)
    if osr.good():
        print("Successfully created example.png")

Rendering an animated GIF::

    from openscad_runner import OpenScadRunner
    osr = OpenScadRunner("example.scad", "example.gif", imgsize=(320,200), animate=36, animate_duration=200)
    osr.run()
    for line in osr.echos:
        print(line)
    for line in osr.warnings:
        print(line)
    for line in osr.errors:
        print(line)
    if osr.good():
        print("Successfully created example.gif")

Rendering an animated PNG::

    from openscad_runner import OpenScadRunner
    osr = OpenScadRunner("example.scad", "example.png", imgsize=(320,200), animate=36, animate_duration=200)
    osr.run()
    for line in osr.echos:
        print(line)
    for line in osr.warnings:
        print(line)
    for line in osr.errors:
        print(line)
    if osr.good():
        print("Successfully created example.png")



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "openscad-runner",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Revar Desmera <revarbat@gmail.com>",
    "keywords": "openscad,interface",
    "author": "",
    "author_email": "Revar Desmera <revarbat@gmail.com>",
    "download_url": "",
    "platform": null,
    "description": "OpenSCAD Runner\n===============\n\nA Python library to interface with and run the OpenSCAD interpreter.\n\nColorScheme Enum Class\n----------------------\n``ColorScheme`` defines the following enums:\n    - cornfield\n    - metallic\n    - sunset\n    - starnight\n    - beforedawn\n    - nature\n    - deepocean\n    - solarized\n    - tomorrow\n    - tomorrow_night\n    - monotone\n\nRenderMode Enum Class\n----------------------\n``RenderMode`` defines the following enums::\n    - test_only\n    - render\n    - preview\n    - thrown_together\n    - wireframe\n\nOpenScadRunner Class\n---------------------\nThe ``OpenScadRunner`` class provides the following methods:\n\n- ``__init__()`` The initializer method, which has the following arguments:\n    - scriptfile = The name of the script file to process.\n    - outfile = The name of the file to output to.\n    - imgsize = The size of the imagefile to output to, if outputting to a PNG or GIF.  Default: (640,480)\n    - antialias = The antialiasing scaling factor.  If greater than 1.0, images are generated at a larger size, then scaled down to the target size with anti-aliasing.  Default: 1.0  (no anti-aliasing)\n    - animate = If given an integer number of frames, creates that many frames of animation, and collates them into an animated GIF or APNG.  Default: None\n    - animate_duration = Number of milliseconds per frame for an animated GIF or APNG.  Default: 250\n    - render_mode = The rendering mode to use when generating an image.  See RenderMode Enum.  Default: RenderMode.preview\n    - show_axes = If True, show axes in the rendering.  Default: True\n    - show_scales = If True, show the scales along the axes.  Default: True\n    - show_edges = If True, shows the edges of all the faces.  Default: False\n    - show_crosshairs = If True, shows the crosshairs for the center of the camera translation.  Default: False\n    - camera = Gives the camera position as either [translate_x,y,z,rot_x,y,z,dist] or [eye_x,y,z,center_x,y,z]\n    - orthographic = If True, render orthographic.  If False, render with perspective.  Default: False\n    - auto_center = If True, and script does not set $vpt, $vpr, or $vpd, then centers the shape in the rendered image.  Default: False\n    - view_all = If True, and script does not set $vpd, then the field of view is scaled to show the complete rendered shape.  Default: False\n    - color_scheme = The color scheme to render an image with.  See ColorScheme Enum.  Default: ColorScheme.cornfield,\n    - csg_limit = If given, the maximum number of CSG elements to render.\n    - deps_file = If given, the file to write Makefile dependancies out to.\n    - make_file = If given, the Makefile script to run when missing a dependency.\n    - set_vars = An optional dictionary of script variables and values to set.\n    - customizer_file = If given, specifies the file containing Customizer Parameters.\n    - customizer_params = An optional dictionary of customizer parameter names and values to set.\n    - hard_warnings = Stop at first WARNING, as if it were an ERROR.  Default: False\n    - quiet = Suppresses non-error, non-warning messages.  Default: False\n- ``good()`` Returns True if the ``run()`` method was called, and processing completed successfully.\n- ``__bool__()`` Returns True if the ``run()`` method was called, and processing completed, whether or not it was successful.\n- ``run()`` Run the OpenSCAD app with the current settings.  This sets some instance variables:\n    - .complete = A boolean value indicating if the processing has completed yet.\n    - .success = A boolean value indicating if the processing completed sucessfully.\n    - .script = The script that was evaluated, as a list of line strings.\n    - .cmdline = The commandline arguments used to launch the OpenSCAD app.\n    - .return_code = The return code from OpenSCAD.  Generally 0 if successful.\n    - .echos = A list of ECHO: output line strings.\n    - .warnings = A list of WARNING: output line strings.\n    - .errors = A list of ERROR: or TRACE: output line strings.\n\n\nCreating an STL file::\n\n    from openscad_runner import OpenScadRunner\n    osr = OpenScadRunner(\"example.scad\", \"example.stl\")\n    osr.run()\n    for line in osr.echos:\n        print(line)\n    for line in osr.warnings:\n        print(line)\n    for line in osr.errors:\n        print(line)\n    if osr.good():\n        print(\"Successfully created example.stl\")\n\nCreating a Preview PNG::\n\n    from openscad_runner import RenderMode, OpenScadRunner\n    osr = OpenScadRunner(\"example.scad\", \"example.png\", render_mode=RenderMode.preview, imgsize=(800,600), antialias=2.0)\n    osr.run()\n    for line in osr.echos:\n        print(line)\n    for line in osr.warnings:\n        print(line)\n    for line in osr.errors:\n        print(line)\n    if osr.good():\n        print(\"Successfully created example.png\")\n\nCreating a Fully Rendered PNG::\n\n    from openscad_runner import RenderMode, OpenScadRunner\n    osr = OpenScadRunner(\"example.scad\", \"example.png\", render_mode=RenderMode.render, imgsize=(800,600), antialias=2.0)\n    osr.run()\n    for line in osr.echos:\n        print(line)\n    for line in osr.warnings:\n        print(line)\n    for line in osr.errors:\n        print(line)\n    if osr.good():\n        print(\"Successfully created example.png\")\n\nRendering an animated GIF::\n\n    from openscad_runner import OpenScadRunner\n    osr = OpenScadRunner(\"example.scad\", \"example.gif\", imgsize=(320,200), animate=36, animate_duration=200)\n    osr.run()\n    for line in osr.echos:\n        print(line)\n    for line in osr.warnings:\n        print(line)\n    for line in osr.errors:\n        print(line)\n    if osr.good():\n        print(\"Successfully created example.gif\")\n\nRendering an animated PNG::\n\n    from openscad_runner import OpenScadRunner\n    osr = OpenScadRunner(\"example.scad\", \"example.png\", imgsize=(320,200), animate=36, animate_duration=200)\n    osr.run()\n    for line in osr.echos:\n        print(line)\n    for line in osr.warnings:\n        print(line)\n    for line in osr.errors:\n        print(line)\n    if osr.good():\n        print(\"Successfully created example.png\")\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python library to interface with the OpenSCAD app.",
    "version": "1.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/revarbat/openscad_runner/issues",
        "Documentation": "https://github.com/revarbat/openscad_runner/README.rst",
        "Homepage": "https://github.com/revarbat/openscad_runner",
        "Releases": "https://github.com/revarbat/openscad_runner/releases",
        "Repository": "https://github.com/revarbat/openscad_runner",
        "Usage": "https://github.com/revarbat/openscad_runner/README.rst"
    },
    "split_keywords": [
        "openscad",
        "interface"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3a2d69128e16545ab696de6f5293f7c147be1313c6f66d4746fbc8acb424f1b",
                "md5": "23dfcdbd3829bf2af103c1becd6759d0",
                "sha256": "e3f6492123191b60bfa85d0b8a63a3aa8ce0634575e8da2a01b5aa8017e244bf"
            },
            "downloads": -1,
            "filename": "openscad_runner-1.1.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "23dfcdbd3829bf2af103c1becd6759d0",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 7931,
            "upload_time": "2024-01-26T06:38:12",
            "upload_time_iso_8601": "2024-01-26T06:38:12.230673Z",
            "url": "https://files.pythonhosted.org/packages/b3/a2/d69128e16545ab696de6f5293f7c147be1313c6f66d4746fbc8acb424f1b/openscad_runner-1.1.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-26 06:38:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "revarbat",
    "github_project": "openscad_runner",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "openscad-runner"
}
        
Elapsed time: 0.18168s