Skip to content

Commit d0c3ad3

Browse files
Merge branch 'master' into patch-2
2 parents a77d916 + cd0c81e commit d0c3ad3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5784
-659
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ target/*
99
MANIFEST
1010
out.*
1111
res?.dxf
12+
.~*
13+
assy.wrl
14+
assy.xml
15+
assy.zip
16+
nested.step
17+
simple.caf
18+
simple.step
19+
simple.stp
20+
simple.xml
21+
test.brep

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ CadQuery is an intuitive, easy-to-use Python module for building parametric 3D C
1515
CadQuery is often compared to [OpenSCAD](http://www.openscad.org/). Like OpenSCAD, CadQuery is an open-source, script based, parametric model generator. However, CadQuery stands out in many ways and has several key advantages:
1616

1717
1. The scripts use a standard programming language, Python, and thus can benefit from the associated infrastructure. This includes many standard libraries and IDEs.
18-
2. CadQuery's CAD kernel Open CASCADE Technology (OCCT) is much more powerful than CGAL. Features supported natively by OCCT include NURBS, splines, surface sewing, STL repair, STEP import/export, and other complex operations, in addition to the standard CSG operations supported by CGAL
19-
3. Ability to import/export STEP and the ability to begin with a STEP model, created in a CAD package, and then add parametric features. This is possible in OpenSCAD using STL, but STL is a lossy format.
18+
2. CadQuery's CAD kernel Open CASCADE Technology ([OCCT](https://en.wikipedia.org/wiki/Open_Cascade_Technology)) is much more powerful than the [CGAL](https://en.wikipedia.org/wiki/CGAL) used by OpenSCAD. Features supported natively by OCCT include NURBS, splines, surface sewing, STL repair, STEP import/export, and other complex operations, in addition to the standard CSG operations supported by CGAL
19+
3. Ability to import/export [STEP](https://en.wikipedia.org/wiki/ISO_10303) and the ability to begin with a STEP model, created in a CAD package, and then add parametric features. This is possible in OpenSCAD using STL, but STL is a lossy format.
2020
4. CadQuery scripts require less code to create most objects, because it is possible to locate features based on the position of other features, workplanes, vertices, etc.
2121
5. CadQuery scripts can build STL, STEP, and AMF faster than OpenSCAD.
2222

azure-pipelines.yml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,7 @@ resources:
1414
name: CadQuery/conda-packages
1515
endpoint: CadQuery
1616

17-
jobs:
18-
- template: conda-build.yml@templates
19-
parameters:
20-
name: Linux_37
21-
vmImage: 'ubuntu-18.04'
22-
py_maj: 3
23-
py_min: 7
24-
25-
- template: conda-build.yml@templates
26-
parameters:
27-
name: macOS_37
28-
vmImage: 'macOS-10.15'
29-
py_maj: 3
30-
py_min: 7
31-
32-
- template: conda-build.yml@templates
33-
parameters:
34-
name: Windows_37
35-
vmImage: 'vs2017-win2016'
36-
py_maj: 3
37-
py_min: 7
38-
conda_bld: 3.18
39-
17+
jobs:
4018
- template: conda-build.yml@templates
4119
parameters:
4220
name: Linux_38

cadquery/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
StringSyntaxSelector,
2828
Selector,
2929
)
30+
from .sketch import Sketch
3031
from .cq import CQ, Workplane
3132
from .assembly import Assembly, Color, Constraint
3233
from . import selectors
@@ -66,6 +67,7 @@
6667
"StringSyntaxSelector",
6768
"Selector",
6869
"plugins",
70+
"Sketch",
6971
]
7072

7173
__version__ = "2.1"

cadquery/assembly.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
ConstraintMarker,
1313
Constraint as ConstraintPOD,
1414
)
15-
from .occ_impl.exporters.assembly import exportAssembly, exportCAF
15+
from .occ_impl.exporters.assembly import (
16+
exportAssembly,
17+
exportCAF,
18+
exportVTKJS,
19+
exportVRML,
20+
exportGLTF,
21+
)
1622

1723
from .selectors import _expression_grammar as _selector_grammar
1824
from OCP.BRepTools import BRepTools
@@ -22,7 +28,7 @@
2228
# type definitions
2329
AssemblyObjects = Union[Shape, Workplane, None]
2430
ConstraintKinds = Literal["Plane", "Point", "Axis", "PointInPlane"]
25-
ExportLiterals = Literal["STEP", "XML"]
31+
ExportLiterals = Literal["STEP", "XML", "GLTF", "VTKJS", "VRML"]
2632

2733
PATH_DELIM = "/"
2834

@@ -168,8 +174,7 @@ def toPOD(self) -> ConstraintPOD:
168174

169175

170176
class Assembly(object):
171-
"""Nested assembly of Workplane and Shape objects defining their relative positions.
172-
"""
177+
"""Nested assembly of Workplane and Shape objects defining their relative positions."""
173178

174179
loc: Location
175180
name: str
@@ -357,7 +362,7 @@ def _subloc(self, name: str) -> Tuple[Location, str]:
357362
"""
358363
Calculate relative location of an object in a subassembly.
359364
360-
Returns the relative posiitons as well as the name of the top assembly.
365+
Returns the relative positions as well as the name of the top assembly.
361366
"""
362367

363368
rv = Location()
@@ -463,18 +468,24 @@ def solve(self) -> "Assembly":
463468
return self
464469

465470
def save(
466-
self, path: str, exportType: Optional[ExportLiterals] = None
471+
self,
472+
path: str,
473+
exportType: Optional[ExportLiterals] = None,
474+
tolerance: float = 0.1,
475+
angularTolerance: float = 0.1,
467476
) -> "Assembly":
468477
"""
469478
save as STEP or OCCT native XML file
470479
471480
:param path: filepath
472481
:param exportType: export format (default: None, results in format being inferred form the path)
482+
:param tolerance: the deflection tolerance, in model units. Only used for GLTF. Default 0.1.
483+
:param angularTolerance: the angular tolerance, in radians. Only used for GLTF. Default 0.1.
473484
"""
474485

475486
if exportType is None:
476487
t = path.split(".")[-1].upper()
477-
if t in ("STEP", "XML"):
488+
if t in ("STEP", "XML", "VRML", "VTKJS", "GLTF"):
478489
exportType = cast(ExportLiterals, t)
479490
else:
480491
raise ValueError("Unknown extension, specify export type explicitly")
@@ -483,6 +494,12 @@ def save(
483494
exportAssembly(self, path)
484495
elif exportType == "XML":
485496
exportCAF(self, path)
497+
elif exportType == "VRML":
498+
exportVRML(self, path)
499+
elif exportType == "GLTF":
500+
exportGLTF(self, path, True, tolerance, angularTolerance)
501+
elif exportType == "VTKJS":
502+
exportVTKJS(self, path)
486503
else:
487504
raise ValueError(f"Unknown format: {exportType}")
488505

0 commit comments

Comments
 (0)