A PNG export plugin for CadQuery.
Project description
cadquery-png-plugin
cadquery-png-plugin is a PNG export plugin for CadQuery, which is a Python API for creating CAD models and assemblies. The core CadQuery library can export SVG images, but not bitmap images, such as PNG.
Installation
This plugin has not been released on PyPI, but it can be installed via git and pip.
pip install git+https://github.com/jmwright/cadquery-png-plugin.git
This installation will also install other required packages such as CadQuery if the environment does not already include them.
Usage
Below is a minimal example of this plugin being used to export a CadQuery assembly.
import cadquery as cq
import cadquery_png_plugin.plugin # This registers the plugin with CadQuery
# You can customize the render options through a dictionary
render_options = {"width": 600, # width of the output image
"height": 600, # height of the output image
"color_theme": "default", # can also be black_and_white
"view": "front-top-right", # front, top, front-bottom-left, etc
"zoom": 1.0 # zooms in and out on the center of the model
}
# Create a simple CadQuery assembly for an example export
box = cq.Workplane().box(10, 10, 10)
cyl = cq.Workplane().circle(2.5).extrude(5)
assy = cq.Assembly(box, color=cq.Color(1.0, 0.0, 0.0))
assy.add(cyl, loc=cq.Location(0, 0, 5.0), color=cq.Color(0.0, 0.0, 1.0))
# Do the PNG export
assy.exportPNG(options=render_options, file_path="ouptput_file.png")
That code results in the following image.
Where this Plugin is Used
An example of this plugin being used by a project in the wild can be found in the Nimble repository.
Running Tests
- Clone the repository.
https://github.com/jmwright/cadquery-png-plugin.git && cd cadquery-png-plugin
- Install the plugin and its development dependencies.
pip install -e .
pip install -e .[dev]
- Run the tests
pytest
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cadquery_png_plugin-1.0.2.tar.gz.
File metadata
- Download URL: cadquery_png_plugin-1.0.2.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1718d9b94c9733f4ed05618da726eeb3408530740a77524756beb1bf5b098c25
|
|
| MD5 |
171c59d80bb2dd2e58c8f5d0a9794cb9
|
|
| BLAKE2b-256 |
504b8f0ac0886e49465095ce892b7dea90166c9db509a93543a41eef494fdc48
|
File details
Details for the file cadquery_png_plugin-1.0.2-py3-none-any.whl.
File metadata
- Download URL: cadquery_png_plugin-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae5ccfd6a60e058dcc7c576b3c73bb83e16fe310785e2f696fb233c30d28c005
|
|
| MD5 |
f13fa1008a15b583dce9ce1ceb1b4ad9
|
|
| BLAKE2b-256 |
888e17a2a6600dc8071a3391a8fe15da22c4bd882676cfc9b511ebed924e3f0a
|