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

calculate

Calculates the transformed vertices of the mesh layer, returns False if this leads to topological or geometrical errors.

setExpressions

Sets the expressions for the coordinates transformation.

text

rtype:

str

transformedVertex

Returns the transformed vertex from its index vertexIndex for the mesh layer

calculate(self, layer: QgsMeshLayer) bool

Calculates the transformed vertices of the mesh layer, returns False 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 mesh layer

If layer is not the same than the one used to make the calculation, this will create an undefined behavior

Parameters:
Return type:

QgsPoint