ezdxf.entities
The POLYLINE entity (POLYLINE DXF Reference) is very complex, it's used to build 2D/3D polylines, 3D meshes and 3D polyfaces. For every type exists a different wrapper class but they all have the same DXF type "POLYLINE". Detect the actual POLYLINE type by the method Polyline.get_mode
.
POLYLINE types returned by Polyline.get_mode
:
'AcDb2dPolyline'
for 2DPolyline
'AcDb3dPolyline'
for 3DPolyline
'AcDbPolygonMesh'
forPolymesh
'AcDbPolyFaceMesh'
forPolyface
For 2D entities all vertices in OCS
.
For 3D entities all vertices in WCS
.
Subclass of | ezdxf.entities.DXFGraphic |
DXF type | 'POLYLINE' |
2D factory function | ezdxf.layouts.BaseLayout.add_polyline2d |
3D factory function | ezdxf.layouts.BaseLayout.add_polyline3d |
Inherited DXF attributes | Common graphical DXF attributes |
Warning
Do not instantiate entity classes by yourself - always use the provided factory functions!
The Vertex
entities are stored in the Python list Polyline.vertices
. The VERTEX entities can be retrieved and deleted by direct access to the Polyline.vertices
attribute:
# delete first and second vertex
del polyline.vertices[:2]
dxf.elevation
Elevation point, the X and Y values are always 0, and the Z value is the polyline elevation (3D Point).
dxf.flags
Constants defined in ezdxf.lldxf.const
:
Polyline.dxf.flags |
Value | Description |
---|---|---|
POLYLINE_CLOSED |
1 |
This is a closed Polyline (or a polygon mesh closed in the M direction) |
POLYLINE_MESH_CLOSED_M_DIRECTION | 1 | equals POLYLINE_CLOSED |
POLYLINE_CURVE_FIT_VERTICES_ADDED | 2 | Curve-fit vertices have been added |
POLYLINE_SPLINE_FIT_VERTICES_ADDED | 4 | Spline-fit vertices have been added |
POLYLINE_3D_POLYLINE | 8 | This is a 3D Polyline |
POLYLINE_3D_POLYMESH | 16 | This is a 3D polygon mesh |
POLYLINE_MESH_CLOSED_N_DIRECTION |
32 |
The polygon mesh is closed in the N direction |
POLYLINE_POLYFACE_MESH | 64 | This Polyline is a polyface mesh |
POLYLINE_GENERATE_LINETYPE_PATTERN |
128 |
The linetype pattern is generated continuously around the vertices of this Polyline |
dxf.default_start_width
Default line start width (float); default is 0
dxf.default_end_width
Default line end width (float); default is 0
dxf.m_count
Polymesh M vertex count (int); default is 1
dxf.n_count
Polymesh N vertex count (int); default is 1
dxf.m_smooth_density
Smooth surface M density (int); default is 0
dxf.n_smooth_density
Smooth surface N density (int); default is 0
dxf.smooth_type
Curves and smooth surface type (int); default is 0, see table below
Constants for smooth_type
defined in ezdxf.lldxf.const
:
Polyline.dxf.smooth_type |
Value | Description |
---|---|---|
POLYMESH_NO_SMOOTH | 0 | no smooth surface fitted |
POLYMESH_QUADRATIC_BSPLINE | 5 | quadratic B-spline surface |
POLYMESH_CUBIC_BSPLINE | 6 | cubic B-spline surface |
POLYMESH_BEZIER_SURFACE | 8 | Bezier surface |
vertices
List of Vertex
entities.
is_2d_polyline
is_3d_polyline
is_polygon_mesh
is_poly_face_mesh
is_closed
is_m_closed
is_n_closed
has_arc
has_width
get_mode
m_close
n_close
close
__len__
__getitem__
points
append_vertex
append_vertices
append_formatted_vertices
insert_vertices
transform
virtual_entities
explode
A VERTEX (VERTEX DXF Reference) represents a polyline/mesh vertex.
Subclass of | ezdxf.entities.DXFGraphic |
DXF type | 'VERTEX' |
Factory function | Polyline.append_vertex |
Factory function | Polyline.extend |
Factory function | Polyline.insert_vertices |
Inherited DXF Attributes | Common graphical DXF attributes |
dxf.location
Vertex location (2D/3D Point OCS
when 2D, WCS
when 3D)
dxf.start_width
Line segment start width (float); default is 0
dxf.end_width
Line segment end width (float); default is 0
dxf.bulge
bulge value
(float); default is 0.
The bulge value is used to create arc shaped line segments.
dxf.flags
Constants defined in ezdxf.lldxf.const
:
Vertex.dxf.flags | Value | Description |
---|---|---|
VTX_EXTRA_VERTEX_CREATED | 1 | Extra vertex created by curve-fitting |
VTX_CURVE_FIT_TANGENT | 2 | curve-fit tangent defined for this vertex. A curve-fit tangent direction of 0 may be omitted from the DXF output, but is significant if this bit is set. |
VTX_SPLINE_VERTEX_CREATED | 8 | spline vertex created by spline-fitting |
VTX_SPLINE_FRAME_CONTROL_POINT | 16 | spline frame control point |
VTX_3D_POLYLINE_VERTEX | 32 | 3D polyline vertex |
VTX_3D_POLYGON_MESH_VERTEX | 64 | 3D polygon mesh |
VTX_3D_POLYFACE_MESH_VERTEX | 128 | polyface mesh vertex |
dxf.tangent
Curve fit tangent direction (float), used for 2D spline in DXF R12.
dxf.vtx1
Index of 1st vertex, if used as face (feature for experts)
dxf.vtx2
Index of 2nd vertex, if used as face (feature for experts)
dxf.vtx3
Index of 3rd vertex, if used as face (feature for experts)
dxf.vtx4
Index of 4th vertex, if used as face (feature for experts)
is_2d_polyline_vertex
is_3d_polyline_vertex
is_polygon_mesh_vertex
is_poly_face_mesh_vertex
is_face_record
format(format='xyz') -> Sequence
Return formatted vertex components as tuple.
Format codes:
- "x" = x-coordinate
- "y" = y-coordinate
- "z" = z-coordinate
- "s" = start width
- "e" = end width
- "b" = bulge value
- "v" = (x, y, z) as tuple
- Args:
format: format string, default is "xyz"
Subclass of | ezdxf.entities.Polyline |
DXF type | 'POLYLINE' |
Factory function | ezdxf.layouts.BaseLayout.add_polymesh |
Inherited DXF Attributes | Common graphical DXF attributes |
A polymesh is a grid of m_count
by n_count
vertices, every vertex has its own (x, y, z) location. The Polymesh
is a subclass of Polyline
, the DXF type is also "POLYLINE", the method get_mode
returns "AcDbPolygonMesh".
get_mesh_vertex
set_mesh_vertex
get_mesh_vertex_cache
Cache mesh vertices in a dict, keys are 0-based (row, col) tuples.
Set vertex location: cache[row, col] = (x, y, z)
Get vertex location: x, y, z = cache[row, col]
vertices
Dict of mesh vertices, keys are 0-based (row, col) tuples.
__getitem__
__setitem__
Subclass of | ezdxf.entities.Polyline |
DXF type | 'POLYLINE' |
Factory function | ezdxf.layouts.BaseLayout.add_polyface |
Inherited DXF Attributes | Common graphical DXF attributes |
tut_polyface
A polyface consist of multiple 3D areas called faces, only faces with 3 or 4 vertices are supported. The Polyface
is a subclass of Polyline
, the DXF type is also "POLYLINE", the ~Polyline.get_mode
returns "AcDbPolyFaceMesh".
append_face
append_faces
faces
optimize