Class: QgsDxfExport¶
Exports QGIS layers to the DXF format.
List of all members, including inherited members
Classes
Encapsulates the properties of a vector layer containing features that will be exported to the DXF file. |
Enums
The result of an export as dxf operation |
|
Horizontal alignments. |
|
Vertical alignments. |
Methods
Add layers to export |
|
Clips value to scale minimum/maximum |
|
Returns the destination CRS, or an invalid CRS if no reprojection will be done. |
|
Gets extent of area to export |
|
Returns any feedback message produced while export to dxf file. |
|
Returns the export flags. |
|
Retrieve whether the output should be forced to 2d |
|
Gets layer name for feature |
|
Retrieve whether layer title (where set) instead of name shall be use |
|
Retrieve map units |
|
Register name of layer for feature |
|
Set destination CRS |
|
Set extent of area to export |
|
Sets the export flags. |
|
Force 2d output (eg. |
|
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer index is -1 |
|
Set map settings and assign layer name attributes |
|
Set symbology export mode |
|
Set reference scale for output. |
|
Gets symbology export mode |
|
Returns the reference scale for output. |
|
Write circle (as polyline) |
|
Write a floating point value |
|
Write filled circle (as hatch) |
|
Write a group code with a string value |
|
Write a group code |
|
Write a group code with a floating point value |
|
Write a tuple of group code and integer value |
|
Write a tuple of group code and long value |
|
Write a group code with a point |
|
Write a tuple of group code and a handle |
|
Write an integer value |
|
Write line (as a polyline) |
|
Write mtext (MTEXT) |
|
Write point |
|
Write a string value |
|
Write text (TEXT) |
|
Static Methods
Gets DXF palette index of nearest entry for given color |
|
Returns DXF encoding for Qt encoding |
|
Returns cleaned layer name for use in DXF |
|
Returns list of available DXF encodings |
|
Returns scale factor for conversion to map units |
- class qgis.core.QgsDxfExport[source]¶
Bases:
object- __init__()
Constructor for QgsDxfExport.
- Closed = 1¶
- ContinuousPattern = 128¶
- Curve = 2¶
- class DxfLayer¶
Bases:
objectEncapsulates the properties of a vector layer containing features that will be exported to the DXF file.
- buildDataDefinedBlocks(self) bool¶
Returns
Trueif data defined point block symbols should be created.Added in version 3.38.
- Return type:
bool
- dataDefinedBlocksMaximumNumberOfClasses(self) int¶
Returns the maximum number of data defined symbol classes for which blocks are created.
- Return type:
int
- Returns:
1 if there is no such limitation
See also
Added in version 3.38.
- layer(self) QgsVectorLayer | None¶
Returns the source vector layer.
- Return type:
- layerOutputAttributeIndex(self) int¶
Returns the attribute index used to split the source layer’s features into multiple exported DXF layers.
Each unique value from the associated attribute will form a separate layer in the exported DXF. The attribute value is used for the DXF layer names.
See also
- Return type:
int
- overriddenName(self) str¶
Returns the overridden layer name to be used in the exported DXF.
If not set the source layer’s name will be used.
Added in version 3.38.
- Return type:
str
- splitLayerAttribute(self) str¶
Returns the name of the field used to split the source layer’s features into multiple exported DXF layers.
Each unique value from the associated attribute will form a separate layer in the exported DXF. The attribute value is used for the DXF layer names.
See also
Added in version 3.12.
- Return type:
str
- class DxfPolylineFlag(*values)¶
Bases:
IntEnum- Closed = 1¶
- ContinuousPattern = 128¶
- Curve = 2¶
- Is3DPolygonMesh = 16¶
- Is3DPolyline = 8¶
- PolyfaceMesh = 64¶
- PolygonMesh = 32¶
- Spline = 4¶
- DxfPolylineFlags()¶
- class ExportResult(*values)¶
Bases:
EnumThe result of an export as dxf operation
Added in version 3.10.1.
Success: Successful exportInvalidDeviceError: Invalid device errorDeviceNotWritableError: Device not writable errorEmptyExtentError: Empty extent, no extent given and no extent could be derived from layers
- DeviceNotWritableError = 2¶
- EmptyExtentError = 3¶
- InvalidDeviceError = 1¶
- Success = 0¶
- class Flag(*values)¶
Bases:
IntEnum- FlagHairlineWidthExport = 8¶
- FlagNoMText = 2¶
- FlagOnlySelectedFeatures = 4¶
- FlagHairlineWidthExport = 8¶
- FlagNoMText = 2¶
- FlagOnlySelectedFeatures = 4¶
- Flags()¶
- class HAlign(*values)¶
Bases:
IntEnumHorizontal alignments.
HLeft: Left (0)HCenter: Centered (1)HRight: Right (2)HAligned: Aligned = (3) (if VAlign==0)HMiddle: Middle = (4) (if VAlign==0)HFit: Fit into point = (5) (if VAlign==0)Undefined: Undefined
- HAligned = 3¶
- HCenter = 1¶
- HFit = 5¶
- HLeft = 0¶
- HMiddle = 4¶
- HRight = 2¶
- Undefined = 9999¶
- Is3DPolygonMesh = 16¶
- Is3DPolyline = 8¶
- PolyfaceMesh = 64¶
- PolygonMesh = 32¶
- Spline = 4¶
- SymbologyExport¶
alias of
FeatureSymbologyExport
- class VAlign(*values)¶
Bases:
IntEnumVertical alignments.
VBaseLine: Top (0)VBottom: Bottom (1)VMiddle: Middle (2)VTop: Top (3)Undefined: Undefined
- Undefined = 9999¶
- VBaseLine = 0¶
- VBottom = 1¶
- VMiddle = 2¶
- VTop = 3¶
- addLayers(self, layers: Iterable[QgsDxfExport.DxfLayer])[source]¶
Add layers to export
- Parameters:
layers (Iterable[QgsDxfExport.DxfLayer]) – list of layers and corresponding attribute indexes that determine the layer name (-1 for original layer name or title)
See also
- clipValueToMapUnitScale(self, scale: QgsMapUnitScale, pixelToMMFactor: float) float[source]¶
Clips value to scale minimum/maximum
- Parameters:
value – the value to clip
scale (QgsMapUnitScale) – the scale dependent minimum/maximum values
pixelToMMFactor (float) – pixels per mm
- Return type:
float
- static closestColorMatch(color: int) int[source]¶
Gets DXF palette index of nearest entry for given color
- Parameters:
color (int)
- Return type:
int
- destinationCrs(self) QgsCoordinateReferenceSystem[source]¶
Returns the destination CRS, or an invalid CRS if no reprojection will be done.
See also
- Return type:
- static dxfEncoding(name: str | None) str[source]¶
Returns DXF encoding for Qt encoding
- Parameters:
name (Optional[str])
- Return type:
str
- static dxfLayerName(name: str | None) str[source]¶
Returns cleaned layer name for use in DXF
- Parameters:
name (Optional[str])
- Return type:
str
- static encodings() list[str][source]¶
Returns list of available DXF encodings
- Return type:
list[str]
- extent(self) QgsRectangle[source]¶
Gets extent of area to export
- Return type:
- Returns:
area to export
See also
- feedbackMessage(self) str[source]¶
Returns any feedback message produced while export to dxf file.
Added in version 3.36.
- Return type:
str
- flags(self) QgsDxfExport.Flag[source]¶
Returns the export flags.
See also
- Return type:
- force2d(self) bool[source]¶
Retrieve whether the output should be forced to 2d
- Return type:
bool
- Returns:
flag
See also
- layerName(self, id: str | None, f: QgsFeature) str[source]¶
Gets layer name for feature
- Parameters:
id (Optional[str]) – layer id of layer
f (QgsFeature) – feature of layer
- Returns:
layer name for feature
layerName(self, vl: Optional[QgsVectorLayer]) -> str Gets name for layer respecting the use layer title as layer name mode
- Parameters:
vl – the vector layer
- Return type:
str
- Returns:
name of layer
See also
- layerTitleAsName(self) bool[source]¶
Retrieve whether layer title (where set) instead of name shall be use
- Return type:
bool
- Returns:
flag
See also
- static mapUnitScaleFactor(scale: float, symbolUnits: Qgis.RenderUnit, mapUnits: Qgis.DistanceUnit, mapUnitsPerPixel: float = 1) float[source]¶
Returns scale factor for conversion to map units
- Parameters:
scale (float) – the map scale denominator
symbolUnits (Qgis.RenderUnit) – the symbol output units
mapUnits (Qgis.DistanceUnit) – the map units
mapUnitsPerPixel (float = 1) – Map units per pixel
- Return type:
float
- mapUnits(self) Qgis.DistanceUnit[source]¶
Retrieve map units
- Return type:
- Returns:
unit
- registerDxfLayer(self, layerId: str | None, fid: int, layer: str | None)[source]¶
Register name of layer for feature
- Parameters:
Deprecated since version 3.40: Will be made private in QGIS 5.
- setDestinationCrs(self, crs: QgsCoordinateReferenceSystem)[source]¶
Set destination CRS
See also
- Parameters:
- setExtent(self, r: QgsRectangle)[source]¶
Set extent of area to export
- Parameters:
r (QgsRectangle) – area to export
- setFlags(self, flags: QgsDxfExport.Flag)[source]¶
Sets the export flags.
See also
- Parameters:
flags (QgsDxfExport.Flag)
- setForce2d(self, force2d: bool)[source]¶
Force 2d output (eg. to support linewidth in polylines)
- Parameters:
force2d (bool) – flag
See also
- setLayerTitleAsName(self, layerTitleAsName: bool)[source]¶
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer index is -1
- Parameters:
layerTitleAsName (bool) – flag
See also
- setMapSettings(self, settings: QgsMapSettings)[source]¶
Set map settings and assign layer name attributes
- Parameters:
settings (QgsMapSettings) – map settings to apply
- setSymbologyExport(self, e: Qgis.FeatureSymbologyExport)[source]¶
Set symbology export mode
- Parameters:
e (Qgis.FeatureSymbologyExport) – the mode
- setSymbologyScale(self, scale: float)[source]¶
Set reference
scalefor output. Thescalevalue indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.See also
- Parameters:
scale (float)
- symbologyExport(self) Qgis.FeatureSymbologyExport[source]¶
Gets symbology export mode
- Return type:
- Returns:
mode
See also
- symbologyScale(self) float[source]¶
Returns the reference scale for output. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
See also
- Return type:
float
- writeCircleV2(self, layer: str | None, color: QColor | Qt.GlobalColor | int, pt: QgsPoint, radius: float, lineStyleName: str | None, width: float)¶
Write circle (as polyline)
- writeDouble(self, d: float)[source]¶
Write a floating point value
- Parameters:
d (float) – floating point value
- writeFillCircleV2(self, layer: str | None, color: QColor | Qt.GlobalColor | int, pt: QgsPoint, radius: float)¶
Write filled circle (as hatch)
Note
available in Python bindings as writePointV2
- writeGroup(self, code: int, s: str | None)[source]¶
Write a group code with a string value
- Parameters:
code (int) – group code
s (Optional[str]) – string value
writeGroup(self, color: Union[QColor, Qt.GlobalColor, int], exactMatch: int = 62, rgbCode: int = 420, transparencyCode: int = 440) Write a group code with color value
- Parameters:
color – color
exactMatch – group code to use if the color has an exact match in the dxf palette
rgbCode – group code to use if the color doesn’t have an exact match or has a transparency component
transparencyCode – group code to use for transparency component
Note
available in Python bindings as writeGroupPoint
- writeGroupCode(self, code: int)[source]¶
Write a group code
- Parameters:
code (int) – group code value
- writeGroupDouble(self, code: int, d: float)¶
Write a group code with a floating point value
- Parameters:
code (int) – group code
d (float) – floating point value
- writeGroupInt(self, code: int, i: int)¶
Write a tuple of group code and integer value
- Parameters:
code (int) – group code
i (int) – integer value
- writeGroupLong(self, code: int, i: int)¶
Write a tuple of group code and long value
- Parameters:
code (int) – group code
i (int) – integer value
- writeGroupPointV2(self, code: int, p: QgsPoint)¶
Write a group code with a point
- Parameters:
code (int) – group code
p (QgsPoint) – point value
- writeHandle(self, code: int = 5, handle: int = 0) int[source]¶
Write a tuple of group code and a handle
- Parameters:
code (int = 5) – group code to use
handle (int = 0) – handle to use (0 generates a new handle)
- Return type:
int
- Returns:
the used handle
- writeLine(self, pt1: QgsPoint, pt2: QgsPoint, layer: str | None, lineStyleName: str | None, color: QColor | Qt.GlobalColor | int, width: float = -1)[source]¶
Write line (as a polyline)
- writeMText(self, layer: str | None, text: str | None, pt: QgsPoint, width: float, angle: float, color: QColor | Qt.GlobalColor | int)[source]¶
Write mtext (MTEXT)
Note
available in Python bindings as writeMTextV2
- writePointV2(self, layer: str | None, color: QColor | Qt.GlobalColor | int, pt: QgsPoint)¶
Write point
- writeString(self, s: str | None)[source]¶
Write a string value
- Parameters:
s (Optional[str]) – string value
- writeTextV2(self, layer: str | None, text: str | None, pt: QgsPoint, size: float, angle: float, color: QColor | Qt.GlobalColor | int, hali: QgsDxfExport.HAlign = QgsDxfExport.HAlign.Undefined, vali: QgsDxfExport.VAlign = QgsDxfExport.VAlign.Undefined)¶
Write text (TEXT)
- writeToFile(self, d: QIODevice | None, codec: str | None) QgsDxfExport.ExportResult[source]¶
- Parameters:
- Return type: