mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Added project_to_viewport to exporters docs
This commit is contained in:
parent
bdaf863e71
commit
a7d2aeb84b
1 changed files with 33 additions and 0 deletions
|
|
@ -108,6 +108,39 @@ specific properties followed by the addition of layers and shapes to the documen
|
||||||
Once all of the layers and shapes have been added, the document can be written
|
Once all of the layers and shapes have been added, the document can be written
|
||||||
to a file.
|
to a file.
|
||||||
|
|
||||||
|
3D to 2D Projection
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
There are a couple ways to generate a 2D drawing of a 3D part:
|
||||||
|
|
||||||
|
* Generate a section: The :func:`~operations_part.section` operation can be used to
|
||||||
|
create a 2D cross section of a 3D part at a given plane.
|
||||||
|
* Generate a projection: The :meth:`~topology.Shape.project_to_viewport` method can be
|
||||||
|
used to create a 2D projection of a 3D scene. Similar to a camera, the ``viewport_origin``
|
||||||
|
defines the location of camera, the ``viewport_up`` defines the orientation of the camera,
|
||||||
|
and the ``look_at`` parameter defined where the camera is pointed. By default,
|
||||||
|
``viewport_up`` is the positive z axis and ``look_up`` is the center of the shape. The
|
||||||
|
return value is a tuple of lists of edges, the first the visible edges and the second
|
||||||
|
the hidden edges.
|
||||||
|
|
||||||
|
Each of these Edges and Faces can be assigned different line color/types and fill colors
|
||||||
|
as described below (as ``project_to_viewport`` only generates Edges, fill doesn't apply).
|
||||||
|
The shapes generated from the above steps are to be added as shapes
|
||||||
|
in one of the exporters described below and written as either a DXF or SVG file as shown
|
||||||
|
in this example:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
view_port_origin=(-100, -50, 30)
|
||||||
|
visible, hidden = part.project_to_viewport(view_port_origin)
|
||||||
|
max_dimension = max(*Compound(children=visible + hidden).bounding_box().size)
|
||||||
|
exporter = ExportSVG(scale=100 / max_dimension)
|
||||||
|
exporter.add_layer("Visible")
|
||||||
|
exporter.add_layer("Hidden", line_color=(99, 99, 99), line_type=LineType.ISO_DOT)
|
||||||
|
exporter.add_shape(visible, layer="Visible")
|
||||||
|
exporter.add_shape(hidden, layer="Hidden")
|
||||||
|
exporter.write("part_projection.svg")
|
||||||
|
|
||||||
LineType
|
LineType
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue