Class: QgsMeshTransformVerticesByExpression¶
- class qgis.core.QgsMeshTransformVerticesByExpression¶
Bases:
QgsMeshAdvancedEditing
Class that can transform vertices of a mesh by expression
Each coordinates are associated with an expression that can be defined with function returning the current coordinates (see
setExpressions()
):$vertex_x
$vertex_y
$vertex_z
Example: Transposing a mesh and translate following axe X with a distance of 50 and increase the level of the mesh with an height of 80 when previous X coordinate is under 100 and de crease the level of 150 when X is under 100:
expressionX: “$vertex_y + 50” expressionY: “$vertex_x” expressionZ: “if( $vertex_x <= 100 , $vertex_z + 80 , $vertex_z - 150)”
New in version 3.22.
QgsMeshTransformVerticesByExpression() Constructor
QgsMeshTransformVerticesByExpression(
QgsMeshTransformVerticesByExpression
)Methods
Calculates the transformed vertices of the mesh
layer
, returnsFalse
if this leads to topological or geometrical errors.Sets the expressions for the coordinates transformation.
- rtype:
str
Returns the transformed vertex from its index
vertexIndex
for the meshlayer
- calculate(self, layer: QgsMeshLayer) bool ¶
Calculates the transformed vertices of the mesh
layer
, returnsFalse
if this leads to topological or geometrical errors. The mesh layer must be in edit mode.Note
this method not apply new vertices to the mesh layer but only store the calculated transformation that can be apply later with
QgsMeshEditor.advancedEdit()
- Parameters:
layer (QgsMeshLayer) –
- Return type:
bool
- setExpressions(self, expressionX: str, expressionY: str, expressionZ: str)¶
Sets the expressions for the coordinates transformation.
Note
Expressions are optional for each coordinate, the coordinate will not be transformed if the string is void.
- Parameters:
expressionX (str) –
expressionY (str) –
expressionZ (str) –
- text(self) str ¶
- Return type:
str
- transformedVertex(self, layer: QgsMeshLayer, vertexIndex: int) QgsPoint ¶
Returns the transformed vertex from its index
vertexIndex
for the meshlayer
If
layer
is not the same than the one used to make the calculation, this will create an undefined behavior- Parameters:
layer (QgsMeshLayer) –
vertexIndex (int) –
- Return type: