-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from Wakoma/generic_rendering
Generic Rendering
- Loading branch information
Showing
6 changed files
with
373 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pylint: disable=too-few-public-methods | ||
#pylint: disable=unused-import | ||
|
||
import cadquery as cq | ||
import cadquery_png_plugin.plugin # This activates the PNG plugin for CadQuery | ||
from cq_annotate.callouts import add_assembly_lines | ||
|
||
def generate_render(model=None, image_format="png", file_path=None, render_options=None): | ||
""" | ||
Generates a render of an assembly. | ||
parameters: | ||
model (cadquery.Assembly): The assembly to render | ||
image_format (str): The format of the image to render (png, svg, gltf, etc) | ||
file_path (str): The path to save the rendered image to | ||
render_options (dict): A dictionary of options to pass to the render function for | ||
things like which view to render,etc | ||
returns: | ||
None | ||
""" | ||
|
||
# Check to see if we are dealing with a single part or an assembly | ||
if isinstance(model, cq.Assembly): | ||
# Handle assembly annotation | ||
if render_options["annotate"]: | ||
add_assembly_lines(model) | ||
|
||
# Handle the varioius image formats separately | ||
if image_format == "png": | ||
model.exportPNG(options=render_options, file_path=file_path) | ||
else: | ||
print("Unknown image format") |
Oops, something went wrong.