{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "pysolid\n=======\n\n- `pysolid: OpenSCAD for Python <#solidpython--openscad-for-python>`__\n- `Advantages <#advantages>`__\n- `Installing pysolid <#installing-solidpython>`__\n- `Using pysolid <#using-solidpython>`__\n- `Example Code <#example-code>`__\n- `Extra syntactic sugar <#extra-syntactic-sugar>`__\n\n - `Basic operators <#basic-operators>`__\n - `First-class Negative Space\n (Holes) <#first-class-negative-space-holes>`__\n - `Animation <#animation>`__\n\n- `solid.utils <#solidutils>`__\n\n - `Directions: (up, down, left, right, forward, back) for arranging\n things: <#directions-up-down-left-right-forward-back-for-arranging-things>`__\n - `Arcs <#arcs>`__\n - `Offsets <#offsets>`__\n - `Extrude Along Path <#extrude_along_path>`__\n - `Basic color library <#basic-color-library>`__\n - `Bill Of Materials <#bill-of-materials>`__\n\n- `solid.screw\\_thread <#solidscrew_thread>`__\n- `Contact <#contact>`__\n- `License <#license>`__\n\npysolid: OpenSCAD for Python\n----------------------------\n\npysolid is a fork of [SolidPython]\n(http://github.com/SolidCode/SolidPython.git), which is a generalization\nof Phillip Tiefenbacher's openscad module, found on\n`Thingiverse `__. It generates\nvalid OpenSCAD code from Python code with minimal overhead. Here's a\nsimple example:\n\nThis Python code:\n\n::\n\n from solid import *\n d = difference()(\n cube(10),\n sphere(15)\n )\n print(scad_render(d))\n\nGenerates this OpenSCAD code:\n\n::\n\n difference(){\n cube(10);\n sphere(15);\n }\n\nThat doesn't seem like such a savings, but the following pysolid code is\na lot shorter (and I think a lot clearer) than the SCAD code it compiles\nto:\n\n::\n\n d = cube(5) + right(5)(sphere(5)) - cylinder(r=2, h=6)\n\nGenerates this OpenSCAD code:\n\n::\n\n difference(){\n union(){\n cube(5);\n translate( [5, 0,0]){\n sphere(5);\n }\n }\n cylinder(r=2, h=6);\n }\n\nAdvantages\n----------\n\nBecause you're using Python, a lot of things are easy that would be hard\nor impossible in pure OpenSCAD. Among these are:\n\n- built-in dictionary types\n- mutable, slice-able list and string types\n- recursion\n- external libraries (images! 3D geometry! web-scraping! ...)\n\nInstalling pysolid\n------------------\n\n- Install via\n `PyPI `__:\n\n ::\n\n pip install pysolid\n\n (You may need to use ``sudo pip install solidpython``, depending on\n your environment.)\n\n- **OR:** Download pysolid (Click\n `here `__ to\n download directly, or use git to pull it all down)\n\n (Note that pysolid also depends on the\n `PyEuclid `__ Vector math\n library, installable via ``sudo pip install euclid``)\n\n - Unzip the file, probably in ~/Downloads/pysolid-master\n - In a terminal, cd to location of file:\n\n ::\n\n cd ~/Downloads/pysolid-master\n\n - Run the install script:\n\n ::\n\n sudo python setup.py --install\n\nUsing pysolid\n-------------\n\n- Include pysolid at the top of your Python file:\n\n ::\n\n from solid import *\n from solid.utils import * # Not required, but the utils module is useful\n\n- To include other scad code, call ``use(\"/path/to/scadfile.scad\")`` or\n ``include(\"/path/to/scadfile.scad\")``. This is identical to what you\n would do in OpenSCAD.\n- OpenSCAD uses curly-brace blocks ({}) to create its tree. pysolid\n uses parentheses with comma-delimited lists. **OpenSCAD:**\n\n ::\n\n difference(){\n cube(10);\n sphere(15);\n }\n\n **pysolid:**\n\n ::\n\n d = difference()(\n cube(10), # Note the comma between each element!\n sphere(15)\n )\n\n- Call ``scad_render(py_scad_obj)`` to generate SCAD code. This returns\n a string of valid OpenSCAD code.\n- *or*: call ``scad_render_to_file(py_scad_obj, filepath)`` to store\n that code in a file.\n- If 'filepath' is open in the OpenSCAD IDE and Design => 'Automatic\n Reload and Compile' is checked (in the OpenSCAD IDE), calling\n ``scad_render_to_file()`` from Python will load the object in the\n IDE.\n- Alternately, you could call OpenSCAD's command line and render\n straight to STL.\n\nExample Code\n------------\n\nThe best way to learn how pysolid works is to look at the included\nexample code. If you've installed pysolid, the following line of Python\nwill print(the location of ) the examples directory:\n\n::\n\n import os, solid; print(os.path.dirname(solid.__file__) + '/examples')\n\nOr browse the example code on Github\n`here `__\n\nAdding your own code to the example file\n`solid/examples/solidpython\\_template.py `__\nwill make some of the setup easier.\n\nExtra syntactic sugar\n---------------------\n\nBasic operators\n~~~~~~~~~~~~~~~\n\nFollowing Elmo M\u00e4ntynen's suggestion, SCAD objects override the basic\noperators + (union), - (difference), and \\* (intersection). So\n\n::\n\n c = cylinder(r=10, h=5) + cylinder(r=2, h=30)\n\nis the same as:\n\n::\n\n c = union()(\n cylinder(r=10, h=5),\n cylinder(r=2, h=30)\n )\n\nLikewise:\n\n::\n\n c = cylinder(r=10, h=5)\n c -= cylinder(r=2, h=30)\n\nis the same as:\n\n::\n\n c = difference()(\n cylinder(r=10, h=5),\n cylinder(r=2, h=30)\n )\n\nFirst-class Negative Space (Holes)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nOpenSCAD requires you to be very careful with the order in which you add\nor subtract objects. pysolid's ``hole()`` function makes this process\neasier.\n\nConsider making a joint where two pipes come together. In OpenSCAD you\nneed to make two cylinders, union them, then make two smaller cylinders,\nunion them, then subtract the smaller from the larger.\n\nUsing hole(), you can make a pipe, specify that its center should remain\nopen, and then add two pipes together knowing that the central void area\nwill stay empty no matter what other objects are added to that\nstructure.\n\nExample:\n\n::\n\n outer = cylinder(r=pipe_od, h=seg_length)\n inner = cylinder(r=pipe_id, h=seg_length)\n pipe_a = outer - hole()(inner)\n\nOnce you've made something a hole, eventually you'll want to put\nsomething, like a bolt, into it. To do this, we need to specify that\nthere's a given 'part' with a hole and that other parts may occupy the\nspace in that hole. This is done with the ``part()`` function.\n\nSee\n`solid/examples/hole\\_example.py `__\nfor the complete picture.\n\nAnimation\n~~~~~~~~~\n\nOpenSCAD has a special variable, ``$t``, that can be used to animate\nmotion. pysolid can do this, too, using the special function\n``scad_render_animated_file()``.\n\nSee\n`solid/examples/animation\\_example.py `__\nfor more details.\n\nsolid.utils\n-----------\n\npysolid includes a number of useful functions in\n`solid/utils.py `__.\nCurrently these include:\n\nDirections: (up, down, left, right, forward, back) for arranging things:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n up(10)(\n cylinder()\n )\n\nseems a lot clearer to me than:\n\n::\n\n translate( [0,0,10])(\n cylinder()\n )\n\n| I took this from someone's SCAD work and have lost track of the\n original author.\n| My apologies.\n\nArcs\n~~~~\n\nI've found this useful for fillets and rounds.\n\n::\n\n arc(rad=10, start_degrees=90, end_degrees=210)\n\ndraws an arc of radius 10 counterclockwise from 90 to 210 degrees.\n\n::\n\n arc_inverted(rad=10, start_degrees=0, end_degrees=90) \n\ndraws the portion of a 10x10 square NOT in a 90 degree circle of radius\n10. This is the shape you need to add to make fillets or remove to make\nrounds.\n\nOffsets\n~~~~~~~\n\nTo offset a set of points in one direction or another (inside or outside\na closed figure, for example) use\n``solid.utils.offset_points(point_arr, offset, inside=True)``\n\nNote that, for a non-convex figure, inside and outside may be\nnon-intuitive. The simple solution is to manually check that your offset\nis going in the direction you intend, and change the boolean value of\n``inside`` if you're not happy.\n\nSee the code for futher explanation. Improvements on the inside/outside\nalgorithm would be welcome.\n\nExtrude Along Path\n~~~~~~~~~~~~~~~~~~\n\n``solid.utils.extrude_along_path(shape_pts, path_pts, scale_factors=None)``\n\nSee\n`solid/examples/path\\_extrude\\_example.py `__\nfor use.\n\nBasic color library\n~~~~~~~~~~~~~~~~~~~\n\nYou can change an object's color by using the OpenSCAD\n``color([rgba_array])`` function:\n\n::\n\n transparent_blue = color([0,0,1, 0.5])(cube(10)) # Specify with RGB[A]\n red_obj = color(Red)(cube(10)) # Or use predefined colors\n\nThese colors are pre-defined in solid.utils:\n\n+------------------+---------------+--------------------+\n| Red | Green | Blue |\n+------------------+---------------+--------------------+\n| Cyan | Magenta | Yellow |\n+------------------+---------------+--------------------+\n| Black | White | Transparent |\n+------------------+---------------+--------------------+\n| Oak | Pine | Birch |\n+------------------+---------------+--------------------+\n| Iron | Steel | Stainless |\n+------------------+---------------+--------------------+\n| Aluminum | Brass | BlackPaint |\n+------------------+---------------+--------------------+\n| FiberBoard | | |\n+------------------+---------------+--------------------+\n\nThey're a conversion of the materials in the `MCAD OpenSCAD\nlibrary `__, as seen [here]\n(https://github.com/openscad/MCAD/blob/master/materials.scad).\n\nBill Of Materials\n~~~~~~~~~~~~~~~~~\n\nPut ``@bom_part()`` before any method that defines a part, then call\n``bill_of_materials()`` after the program is run, and all parts will be\ncounted, priced and reported.\n\nThe example file\n`solid/examples/bom\\_scad.py `__\nillustrates this. Check it out.\n\nsolid.screw\\_thread\n===================\n\nsolid.screw\\_thread includes a method, thread() that makes internal and\nexternal screw threads.\n\nSee\n`solid/examples/screw\\_thread\\_example.py `__\nfor more details.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pysolid", "package_url": "https://pypi.org/project/pysolid/", "platform": null, "project_url": "https://pypi.org/project/pysolid/", "project_urls": null, "release_url": "https://pypi.org/project/pysolid/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Python interface to the OpenSCAD declarative geometry language", "version": "0.0.1" }, "last_serial": 2286081, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "881a8b256d49af9c887353d8bea4ca8f", "sha256": "2f3de4277e83a334314e1da4546de28e23150f4be186ff9c218972107aca8581" }, "downloads": -1, "filename": "pysolid-0.0.1.tar.gz", "has_sig": false, "md5_digest": "881a8b256d49af9c887353d8bea4ca8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 58087, "upload_time": "2016-08-17T12:40:52", "url": "https://files.pythonhosted.org/packages/85/4d/097a1b1f465ca676a8a62e766ec7e21432e8950fd0ff07b79fb9c7a906cd/pysolid-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "881a8b256d49af9c887353d8bea4ca8f", "sha256": "2f3de4277e83a334314e1da4546de28e23150f4be186ff9c218972107aca8581" }, "downloads": -1, "filename": "pysolid-0.0.1.tar.gz", "has_sig": false, "md5_digest": "881a8b256d49af9c887353d8bea4ca8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 58087, "upload_time": "2016-08-17T12:40:52", "url": "https://files.pythonhosted.org/packages/85/4d/097a1b1f465ca676a8a62e766ec7e21432e8950fd0ff07b79fb9c7a906cd/pysolid-0.0.1.tar.gz" } ] }