Docs update
This commit is contained in:
BIN
doc/_static/assy.png
vendored
Normal file
BIN
doc/_static/assy.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 136 KiB |
BIN
doc/_static/simple_assy.png
vendored
Normal file
BIN
doc/_static/simple_assy.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
@ -9,14 +9,14 @@ methods:
|
||||
|
||||
* You can load plugins others have developed. This is by far the easiest way to access other code
|
||||
* You can define your own plugins.
|
||||
* You can use PythonOCC scripting directly
|
||||
* You can use OCP scripting directly
|
||||
|
||||
|
||||
Using PythonOCC Script
|
||||
-----------------------
|
||||
Using OpenCascade methods
|
||||
-------------------------
|
||||
|
||||
The easiest way to extend CadQuery is to simply use PythonOCC scripting inside of your build method. Just about
|
||||
any valid PythonOCC script will execute just fine. For example, this simple CadQuery script::
|
||||
The easiest way to extend CadQuery is to simply use OpenCascade/OCP scripting inside of your build method. Just about
|
||||
any valid OCP script will execute just fine. For example, this simple CadQuery script::
|
||||
|
||||
return cq.Workplane("XY").box(1.0,2.0,3.0).val()
|
||||
|
||||
@ -24,8 +24,8 @@ is actually equivalent to::
|
||||
|
||||
return cq.Shape.cast(BRepPrimAPI_MakeBox(gp_Ax2(Vector(-0.1, -1.0, -1.5), Vector(0, 0, 1)), 1.0, 2.0, 3.0).Shape())
|
||||
|
||||
As long as you return a valid PythonOCC Shape, you can use any PythonOCC methods you like. You can even mix and match the
|
||||
two. For example, consider this script, which creates a PythonOCC box, but then uses CadQuery to select its faces::
|
||||
As long as you return a valid OCP Shape, you can use any OCP methods you like. You can even mix and match the
|
||||
two. For example, consider this script, which creates a OCP box, but then uses CadQuery to select its faces::
|
||||
|
||||
box = cq.Shape.cast(BRepPrimAPI_MakeBox(gp_Ax2(Vector(-0.1, -1.0, -1.5), Vector(0, 0, 1)), 1.0, 2.0, 3.0).Shape())
|
||||
cq = Workplane(box).faces(">Z").size() # returns 6
|
||||
@ -34,10 +34,10 @@ two. For example, consider this script, which creates a PythonOCC box, but then
|
||||
Extending CadQuery: Plugins
|
||||
----------------------------
|
||||
|
||||
Though you can get a lot done with PythonOCC, the code gets pretty nasty in a hurry. CadQuery shields you from
|
||||
a lot of the complexity of the PythonOCC API.
|
||||
Though you can get a lot done with OpenCascade, the code gets pretty nasty in a hurry. CadQuery shields you from
|
||||
a lot of the complexity of the OpenCascade API.
|
||||
|
||||
You can get the best of both worlds by wrapping your PythonOCC script into a CadQuery plugin.
|
||||
You can get the best of both worlds by wrapping your OCP script into a CadQuery plugin.
|
||||
|
||||
A CadQuery plugin is simply a function that is attached to the CadQuery :py:meth:`cadquery.CQ` or :py:meth:`cadquery.Workplane` class.
|
||||
When connected, your plugin can be used in the chain just like the built-in functions.
|
||||
@ -51,8 +51,8 @@ The Stack
|
||||
Every CadQuery object has a local stack, which contains a list of items. The items on the stack will be
|
||||
one of these types:
|
||||
|
||||
* **A CadQuery SolidReference object**, which holds a reference to a PythonOCC solid
|
||||
* **A PythonOCC object**, a Vertex, Edge, Wire, Face, Shell, Solid, or Compound
|
||||
* **A CadQuery SolidReference object**, which holds a reference to a OCP solid
|
||||
* **A OCP object**, a Vertex, Edge, Wire, Face, Shell, Solid, or Compound
|
||||
|
||||
The stack is available by using self.objects, and will always contain at least one object.
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ CadQuery is an intuitive, easy-to-use Python library for building parametric 3D
|
||||
* Provide a non-proprietary, plain text model format that can be edited and executed with only a web browser
|
||||
|
||||
CadQuery 2.0 is based on
|
||||
`PythonOCC <http://www.pythonocc.org/>`_,
|
||||
`OCP https://github.com/CadQuery/OCP`_,
|
||||
which is a set of Python bindings for the open-source `OpenCascade <http://www.opencascade.com/>`_ modelling kernel.
|
||||
|
||||
Using CadQuery, you can build fully parametric models with a very small amount of code. For example, this simple script
|
||||
@ -54,8 +54,7 @@ its use in a variety of engineering and scientific applications that create 3D m
|
||||
If you'd like a GUI, you have a couple of options:
|
||||
|
||||
* The Qt-based GUI `CQ-editor <https://github.com/CadQuery/CQ-editor>`_
|
||||
* As an Jupyter extension `cadquery-jupyter-extension
|
||||
<https://github.com/bernhard-42/cadquery-jupyter-extension>`_
|
||||
* As an Jupyter extension `jupyter-cadquery <https://github.com/bernhard-42/jupyter-cadquery>`_
|
||||
|
||||
|
||||
Why CadQuery instead of OpenSCAD?
|
||||
@ -70,7 +69,7 @@ Like OpenSCAD, CadQuery is an open-source, script based, parametric model genera
|
||||
by OCC include NURBS, splines, surface sewing, STL repair, STEP import/export, and other complex operations,
|
||||
in addition to the standard CSG operations supported by CGAL
|
||||
|
||||
3. **Ability to import/export STEP** We think the ability to begin with a STEP model, created in a CAD package,
|
||||
3. **Ability to import/export STEP and DXF** We think the ability to begin with a STEP model, created in a CAD package,
|
||||
and then add parametric features is key. This is possible in OpenSCAD using STL, but STL is a lossy format
|
||||
|
||||
4. **Less Code and easier scripting** CadQuery scripts require less code to create most objects, because it is possible to locate
|
||||
|
||||
@ -168,16 +168,30 @@ This is really useful to remember when you author your own plugins. :py:meth:`c
|
||||
Assemblies
|
||||
----------
|
||||
|
||||
Simple models can be combined into complex, possibly nested, assemblies::
|
||||
Simple models can be combined into complex, possibly nested, assemblies.
|
||||
|
||||
part1 = Workplane().box(1,1,1)
|
||||
part2 = Workplane().box(1,1,2)
|
||||
part3 = Workplane().box(1,1,3)
|
||||
.. image:: _static/assy.png
|
||||
|
||||
A simple example could look as follows::
|
||||
|
||||
from cadquery import *
|
||||
|
||||
w = 10
|
||||
d = 10
|
||||
h = 10
|
||||
|
||||
part1 = Workplane().box(2*w,2*d,h)
|
||||
part2 = Workplane().box(w,d,2*h)
|
||||
part3 = Workplane().box(w,d,3*h)
|
||||
|
||||
assy = (
|
||||
Assembly(part1, Location((1,0,0)))
|
||||
.add(part2, Location(1,0,0))
|
||||
.add(part3, Location(-1,0,0))
|
||||
Assembly(part1, loc=Location(Vector(-w,0,h/2)))
|
||||
.add(part2, loc=Location(Vector(1.5*w,-.5*d,h/2)), color=Color(0,0,1,0.5))
|
||||
.add(part3, loc=Location(Vector(-.5*w,-.5*d,2*h)), color=Color("red"))
|
||||
)
|
||||
|
||||
Note that the locations of the children parts are defined with respect to their parents - in the above example ``part3`` will be located at (0,0,0) in the global coordinate system.
|
||||
Resulting in:
|
||||
|
||||
.. image:: _static/simple_assy.png
|
||||
|
||||
Note that the locations of the children parts are defined with respect to their parents - in the above example ``part3`` will be located at (-5,-5,20) in the global coordinate system. Assemblies with different colors can be created this way and exported to STEP or the native OCCT xml format.
|
||||
|
||||
Reference in New Issue
Block a user