Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shape.workplane can now accept a cadquery.Plane object #84

Merged
merged 6 commits into from
Sep 18, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions paramak/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import List, Optional, Tuple, Union

import matplotlib.pyplot as plt
from cadquery import Assembly, Color, Compound, Workplane, exporters, importers
from cadquery import Assembly, Color, Compound, Workplane, exporters, importers, Plane
from cadquery.occ_impl import shapes
from matplotlib.collections import PatchCollection
from matplotlib.patches import Polygon
Expand Down Expand Up @@ -88,7 +88,7 @@ def __init__(
stp_filename: Optional[str] = None,
stl_filename: Optional[str] = None,
azimuth_placement_angle: Optional[Union[float, List[float]]] = 0.0,
workplane: Optional[str] = "XZ",
workplane: Optional[Union[str, Plane]] = "XZ",
rotation_axis: Optional[str] = None,
tet_mesh: Optional[str] = None,
scale: Optional[float] = None,
Expand Down Expand Up @@ -276,14 +276,21 @@ def workplane(self):
@workplane.setter
def workplane(self, value):
acceptable_values = ["XY", "YZ", "XZ", "YX", "ZY", "ZX"]
if value in acceptable_values:
self._workplane = value
if not isinstance(value, Plane):
if value in acceptable_values:
self._workplane = value
elif isinstance(value, str):
raise ValueError(
"Shape.workplane must be one of ",
acceptable_values,
" not ",
value)
else:
raise TypeError(
"Shape.workplane must be a string or a ",
"cadquery.Plane object")
else:
raise ValueError(
"Shape.workplane must be one of ",
acceptable_values,
" not ",
value)
self._workplane = value

@property
def rotation_axis(self):
Expand Down