Skip to content

Commit

Permalink
Merge pull request #47 from gumyr/dev
Browse files Browse the repository at this point in the history
New Sketch Methods
  • Loading branch information
gumyr authored Jun 12, 2022
2 parents 65f283b + 23dc7f2 commit ba9084b
Show file tree
Hide file tree
Showing 29 changed files with 838 additions and 91 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ The documentation for **cq_warehouse** can found at [readthedocs](https://cq-war
To install **cq_warehouse** from github:
```
python3 -m pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
```
To install the working `dev` branch:
```
python3 -m pip install git+https://github.com/gumyr/cq_warehouse.git@dev#egg=cq_warehouse
```
Binary file removed dist/cq_warehouse-0.0.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cq_warehouse-0.0.1.tar.gz
Binary file not shown.
Binary file removed dist/cq_warehouse-0.1.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cq_warehouse-0.1.0.tar.gz
Binary file not shown.
Binary file removed dist/cq_warehouse-0.2.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cq_warehouse-0.2.0.tar.gz
Binary file not shown.
Binary file removed dist/cq_warehouse-0.3.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cq_warehouse-0.3.0.tar.gz
Binary file not shown.
Binary file removed dist/cq_warehouse-0.5.3-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cq_warehouse-0.5.3.tar.gz
Binary file not shown.
Binary file removed dist/cq_warehouse-0.6.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cq_warehouse-0.6.0.tar.gz
Binary file not shown.
Binary file removed dist/cq_warehouse-0.7.0-py3-none-any.whl
Binary file not shown.
Binary file removed dist/cq_warehouse-0.7.0.tar.gz
Binary file not shown.
12 changes: 10 additions & 2 deletions docs/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Currently, cq_warehouse.extensions augments these four CadQuery source files:

* assembly.py,
* cq.py,
* geom.py, and
* shapes.py.
* geom.py,
* shapes.py, and
* sketch.py.

Usage:

Expand Down Expand Up @@ -113,6 +114,13 @@ Shape class extensions
.. autoclass:: Shape
:members:

***********************
Sketch class extensions
***********************

.. autoclass:: Sketch
:members:

***********************
Vector class extensions
***********************
Expand Down
1 change: 1 addition & 0 deletions docs/finger_jointed_boxes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The full API is as follows:
:noindex:

.. automethod:: Workplane.makeFingerJoints
:noindex:

The ``kerfWidth`` parameter can be used to compensate for the size of the laser cut
thus allowing a path for the laser to the created directly from the face. Check with
Expand Down
17 changes: 11 additions & 6 deletions examples/embossing.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,32 @@ class Testcase(Enum):
50, 100, pnt=cq.Vector(0, 0, -50), dir=cq.Vector(0, 0, 1)
)
path = cq.Workplane(target_object).section().edges().val()
to_emboss_wire = cq.Wire.makeRect(
80, 40, cq.Vector(), cq.Vector(0, 0, 1), cq.Vector(1, 0, 0)
)
# to_emboss_wire = cq.Wire.makeRect(
# 80, 40, cq.Vector(), cq.Vector(0, 0, 1), cq.Vector(1, 0, 0)
# )
to_emboss_wire = cq.Workplane("XY").slot2D(80, 40).wires().val()
embossed_wire = to_emboss_wire.embossToShape(
targetObject=target_object,
surfacePoint=path.positionAt(0),
surfaceXDirection=path.tangentAt(0),
tolerance=0.1,
)
embossed_edges = embossed_wire.Edges()
for i, e in enumerate(to_emboss_wire.Edges()):
embossed_edges = embossed_wire.sortedEdges()
for i, e in enumerate(to_emboss_wire.sortedEdges()):
target = e.Length()
actual = embossed_edges[i].Length()
print(
f"Edge lengths: target {target}, actual {actual}, difference {abs(target-actual)}"
)

sweep_profile = cq.Wire.makeCircle(
3, center=embossed_wire.positionAt(0), normal=embossed_wire.tangentAt(0)
)
swept_wire = cq.Solid.sweep(sweep_profile, [], path=embossed_wire)
print(f"Example #{example} time: {timeit.default_timer() - starttime:0.2f}s")

if "show_object" in locals():
show_object(target_object, name="target_object", options={"alpha": 0.8})
show_object(path, name="path")
show_object(to_emboss_wire, name="to_emboss_wire")
show_object(embossed_wire, name="embossed_wire")
show_object(swept_wire, name="swept_wire")
6 changes: 3 additions & 3 deletions examples/text_on_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Extensions Examples
name: text_on_path.py
name: txt_on_path.py
by: Gumyr
date: January 10th 2022
desc: Create 3D text on a path on many planes.
desc: Create 3D txt on a path on many planes.
license:
Expand Down Expand Up @@ -53,7 +53,7 @@
txt=base_plane + " The quick brown fox jumped over the lazy dog",
fontsize=5,
distance=1,
start=0.05,
positionOnPath=0.05,
)
)
if "show_object" in locals():
Expand Down
12 changes: 10 additions & 2 deletions scripts/build_cadquery_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
and generates extended versions of these files:
- assembly.py,
- cq.py,
- sketch.py,
- geom.py, and
- shapes.py.
Finally, a diff is generated between the originals and extended files for use
Expand Down Expand Up @@ -67,6 +68,7 @@
class_files = {
"occ_impl/shapes.py": ["Shape", "Vertex", "Edge", "Wire", "Face", "Module"],
"assembly.py": ["Assembly"],
"sketch.py": ["Sketch"],
"cq.py": ["Workplane"],
"occ_impl/geom.py": ["Plane", "Vector", "Location"],
}
Expand Down Expand Up @@ -446,6 +448,12 @@ def main(argv):
],
stdout=patch_file,
)
# Extract the second line to determine the patch depth
with open(patch_file_name, "r") as patch_file:
patch_file.readline()
first_line = patch_file.readline()
patch_depth = first_line.split()[1].count("/")

# Copy the patch to the cadquery original source directory
shutil.copyfile(
patch_file_name,
Expand All @@ -457,9 +465,9 @@ def main(argv):
)
print("To apply the patch:")
print(f" cd {cadquery_path}")
print(f" patch -s -p4 < {patch_file_name}")
print(f" patch -s -l -p{patch_depth} < {patch_file_name}")
print("To reverse the patch:")
print(f" patch -R -p4 < {patch_file_name}")
print(f" patch -R -l -p{patch_depth} < {patch_file_name}")


if __name__ == "__main__":
Expand Down
6 changes: 4 additions & 2 deletions scripts/build_extensions_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
and generates extended versions of these files:
- assembly.py,
- cq.py,
- geom.py, and
- shapes.py.
- geom.py,
- shapes.py, and
- sketch.py.
Finally, a diff is generated between the originals and extended files for use
with the patch command.
Expand Down Expand Up @@ -303,6 +304,7 @@ def main(argv):
"class Solid:\n pass\n",
"class Compound:\n pass\n",
"class Location:\n pass\n",
"Modes = Literal['a', 's', 'i', 'c']\n",
]
)
for class_name, method_dictionaries in extensions_code_dictionary.items():
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = cq_warehouse
version = 0.7.0
version = 0.7.1
author = Gumyr
author_email = [email protected]
description = A cadquery parametric part collection
Expand Down
2 changes: 1 addition & 1 deletion src/cq_warehouse.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: cq-warehouse
Version: 0.7.0
Version: 0.7.1
Summary: A cadquery parametric part collection
Home-page: https://github.com/gumyr/cq_warehouse
Author: Gumyr
Expand Down
1 change: 1 addition & 0 deletions src/cq_warehouse.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ src/cq_warehouse/single_row_capped_deep_groove_ball_bearing_parameters.csv
src/cq_warehouse/single_row_cylindrical_roller_bearing_parameters.csv
src/cq_warehouse/single_row_deep_groove_ball_bearing_parameters.csv
src/cq_warehouse/single_row_tapered_roller_bearing_parameters.csv
src/cq_warehouse/sketch_extended.py
src/cq_warehouse/socket_head_cap_parameters.csv
src/cq_warehouse/sprocket.py
src/cq_warehouse/square_nut_parameters.csv
Expand Down
Loading

0 comments on commit ba9084b

Please sign in to comment.