QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
23 QString QgsDxfExportAlgorithm::name()
const
25 return QStringLiteral(
"dxfexport" );
28 QString QgsDxfExportAlgorithm::displayName()
const
30 return QObject::tr(
"Export layers to DXF" );
33 QStringList QgsDxfExportAlgorithm::tags()
const
35 return QObject::tr(
"layer,export,dxf,cad,dwg" ).split(
',' );
38 QString QgsDxfExportAlgorithm::group()
const
40 return QObject::tr(
"Vector general" );
43 QString QgsDxfExportAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeneral" );
48 QString QgsDxfExportAlgorithm::shortHelpString()
const
50 return QObject::tr(
"Exports layers to DXF file. For each layer, you can choose a field whose values are used to split features in generated destination layers in the DXF output." );
53 QgsDxfExportAlgorithm *QgsDxfExportAlgorithm::createInstance()
const
55 return new QgsDxfExportAlgorithm();
58 void QgsDxfExportAlgorithm::initAlgorithm(
const QVariantMap & )
61 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"SYMBOLOGY_MODE" ), QObject::tr(
"Symbology mode" ), QStringList() << QObject::tr(
"No Symbology" ) << QObject::tr(
"Feature Symbology" ) << QObject::tr(
"Symbol Layer Symbology" ),
false, 0 ) );
64 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS" ), QObject::tr(
"CRS" ), QStringLiteral(
"EPSG:4326" ) ) );
76 QList<QgsVectorLayer *> mapLayers;
78 const QVariant layersVariant = parameters.value( parameterDefinition( QStringLiteral(
"LAYERS" ) )->name() );
85 mapLayers.push_back( layer.layer() );
89 const double symbologyScale = parameterAsDouble( parameters, QStringLiteral(
"SYMBOLOGY_SCALE" ), context );
90 const QString encoding = parameterAsEnumString( parameters, QStringLiteral(
"ENCODING" ), context );
92 const bool useLayerTitle = parameterAsBool( parameters, QStringLiteral(
"USE_LAYER_TITLE" ), context );
93 const bool useMText = parameterAsBool( parameters, QStringLiteral(
"MTEXT" ), context );
94 const bool force2D = parameterAsBool( parameters, QStringLiteral(
"FORCE_2D" ), context );
95 const QString outputFile = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
107 QgsDxfExport::Flags flags = QgsDxfExport::Flags();
112 QFile dxfFile( outputFile );
113 switch ( dxfExport.
writeToFile( &dxfFile, encoding ) )
116 feedback->
pushInfo( QObject::tr(
"DXF export completed" ) );
133 outputs.insert( QStringLiteral(
"OUTPUT" ), outputFile );
static QStringList encodings()
Returns list of available DXF encodings.
Exports QGIS layers to the DXF format.
void addLayers(const QList< QgsDxfExport::DxfLayer > &layers)
Add layers to export.
void setSymbologyExport(QgsDxfExport::SymbologyExport e)
Set symbology export mode.
Base class for providing feedback from a processing algorithm.
const QgsCoordinateReferenceSystem & crs
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Set destination CRS.
@ FlagNoMText
Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
@ EmptyExtentError
Empty extent, no extent given and no extent could be derived from layers.
A double numeric parameter for map scale values.
ExportResult writeToFile(QIODevice *d, const QString &codec)
Export to a dxf file in the given encoding.
A coordinate reference system parameter for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
void setSymbologyScale(double scale)
Set reference scale for output.
A parameter for Processing algorithms that need a list of input vector layers to export as DXF file -...
void setFlags(QgsDxfExport::Flags flags)
Sets the export flags.
void setMapSettings(const QgsMapSettings &settings)
Set map settings and assign layer name attributes.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
This class represents a coordinate reference system (CRS).
void setForce2d(bool force2d)
Force 2d output (eg.
@ DeviceNotWritableError
Device not writable error.
A boolean parameter for processing algorithms.
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
@ InvalidDeviceError
Invalid device error.
static QList< QgsDxfExport::DxfLayer > parameterAsLayers(const QVariant &layersVariant, QgsProcessingContext &context)
Converts a QVariant value (a QVariantList) to a list of input layers.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
void setLayerTitleAsName(bool layerTitleAsName)
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer in...
Custom exception class for processing related exceptions.
@ Success
Successful export.