{"id":27329434,"url":"https://github.com/csirmaz/openscad-py","last_synced_at":"2026-05-01T19:33:58.194Z","repository":{"id":211798355,"uuid":"729968645","full_name":"csirmaz/openscad-py","owner":"csirmaz","description":"Python OOP precompiler for OpenSCAD's language","archived":false,"fork":false,"pushed_at":"2025-12-14T19:34:12.000Z","size":266,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-17T07:17:27.005Z","etag":null,"topics":["3d-models","3d-printing","cad","numpy","openscad","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csirmaz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-10T22:24:46.000Z","updated_at":"2025-12-14T19:34:16.000Z","dependencies_parsed_at":"2025-04-12T12:35:10.728Z","dependency_job_id":"5f99d6e4-6b48-4e1a-aa2c-6cffda763be1","html_url":"https://github.com/csirmaz/openscad-py","commit_stats":null,"previous_names":["csirmaz/openscad-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/csirmaz/openscad-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csirmaz%2Fopenscad-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csirmaz%2Fopenscad-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csirmaz%2Fopenscad-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csirmaz%2Fopenscad-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csirmaz","download_url":"https://codeload.github.com/csirmaz/openscad-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csirmaz%2Fopenscad-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32510807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-models","3d-printing","cad","numpy","openscad","python"],"created_at":"2025-04-12T12:33:09.142Z","updated_at":"2026-05-01T19:33:58.181Z","avatar_url":"https://github.com/csirmaz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openscad-py\n\nA Python OOP precompiler for OpenSCAD's language\n\n[OpenSCAD](https://openscad.org/) uses a functional scripting language to define solid 3D CAD models.\nAs such, it is a prefix language (modifiers go before the things they modify).\n\nOpenSCADPy allows one to write OpenSCAD scripts using an object representation, which uses method calls\nto describe modifications. This way, modifications are written after the objects they modify in a postfix\nfashion, more closely resembling a procedural ordering of steps in the creation of the models.\n\nIt also contains convenience functions to define a wider range of primitives, vector operations, and a method\nto export polyhedra directly to STL.\n\n## Example\n\n```python\n# example.py\nfrom openscad_py import Cube\n\ncolored_moved_cube = Cube([1, 1, 1]).move([2, 0, 0]).color(r=1, g=0, b=0)\nprint(colored_moved_cube.render())\n```\n\nprints the OpenSCAD code\n\n```\n# example.scad\ncolor(c=[1,0,0,1.0]){ translate(v=[2.0,0.0,0.0]){\ncube(size=[1.0,1.0,1.0], center=false);\n} }\n```\n\nAn easy way to write and render the OpenSCAD code would be\n\n```\n$ python3 example.py \u003e example.scad\n$ openscad example.scad\n```\n\n## Notable convenience functions\n\n### Computational geometry\n\nUsual computational geometry functions are implemented in the \n[`Point` class](https://csirmaz.codeberg.page/openscad-py/@reference/point.html)\nthat work in an arbitrary number of dimensions. Overloads algebraic operators. Examples:\n\n```python\ndistance = (Point((0, 0, 1)) - Point((1, 0, 1))).length()\nangle_between = Point((0, 0, 1) * 2).angle(Point((1, 0, 1)))\n```\n\n### Cylinders\n\n`Cylinder.from_ends()` constructs a cylinder between two given points in space. Example:\n\n```python\nopenscad_code = Cylinder.from_ends(radius=2, p1=(0, 0, 1), p2=(1, 0, 2)).render()\n```\n\n### Tubes and toroids from a point grid\n\n[`Polyhedron.tube()`](https://csirmaz.codeberg.page/openscad-py/@reference/polyhedron.html#openscad_py.polyhedron.Polyhedron.tube) \ncreates a tube-like Polyhedron object from a 2D array of points.\n\n[`Polyhedron.torus()`](https://csirmaz.codeberg.page/openscad-py/@reference/polyhedron.html#openscad_py.polyhedron.Polyhedron.torus)\ncreates a toroid Polyhedron object from a 2D array of points.\n\n### Tubes from a path\n\n[`PathTube`](https://csirmaz.codeberg.page/openscad-py/@reference/path_tube.html)\ncreates a tube-like or toroid Polyhedron object from an arbitrary path. Example:\n\n```python\nPathTube(\n    points=[(0,0,0), (0,0,1), (1,0,2), (1,1,0), (0,.5,0)],\n    radius=.2,\n    fn=4\n)\n```\n\n![PathTube example](https://www.postminart.com/cdn/pathtube.png)\n\n### Polyhedron from a height map\n\n[`Polyhedron.from_heightmap()`](https://csirmaz.codeberg.page/openscad-py/@reference/polyhedron.html#openscad_py.polyhedron.Polyhedron.from_heightmap)\ncreates a Polyhedron object from a 2D matrix of heights. Example:\n\n```python\nPolyhedron.from_heightmap(\n    heights=[\n        [3, 3, 1, 1, 1],\n        [3, 3, 1, 1, 1],\n        [1, 1, 1, 1, 1],\n        [1, 1, 1, 2, 2],\n        [1, 1, 1, 2, 2],\n    ],\n    base=-5\n)\n```\n\n![Heightmap example](https://www.postminart.com/cdn/heightmap.png)\n\n### Direct STL export\n\n[`Polyhedron.render_stl()`](https://csirmaz.codeberg.page/openscad-py/@reference/polyhedron.html#openscad_py.polyhedron.Polyhedron.render_stl)\nexports a Polyhedron object into STL directly.\nThis works well with `tube()`, `torus()`, `from_heightmap()` and `PathTube` described above. \nNote that the polyhedron object cannot be post-modified (e.g. by `union`, `difference`) - if so, \nuse OpenSCAD to render the object and export to STL.\n\n## Overview and usage\n\nIn `openscad_py`, all objects (including derived ones) come with a large set of convenience methods\nto apply transformations, implemented in the base [`Object` class](https://csirmaz.codeberg.page/openscad-py/@reference/object_.html).\nThis allows to freely specify transformations on any object:\n\n```python\nmoved_cube = Cube([1, 1, 1]).move([2, 0, 0])\ncolored_moved_cube = Cube([1, 1, 1]).move([2, 0, 0]).color(r=1, g=0, b=0)\n```\n\nOnce the desired object has been created, call `render()` on the final object to obtain the\nOpenSCAD code.\n\n## Reference\n\nSee https://csirmaz.codeberg.page/openscad-py/@reference/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsirmaz%2Fopenscad-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsirmaz%2Fopenscad-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsirmaz%2Fopenscad-py/lists"}