Class: QgsMeshTransformVerticesByExpression¶
Transforms 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)”
Added in version 3.22.
Class Hierarchy¶
Base classes¶
Abstract class that can be derived to implement advanced editing on mesh. |
Methods
Calculates the transformed vertices of the mesh layer, returns |
|
Sets the expressions for the coordinates transformation. |
|
Sets if Z values for vertices should be obtained from project terrain, instead of expression. |
|
Returns the transformed vertex from its index vertexIndex for the mesh layer |
- class qgis.core.QgsMeshTransformVerticesByExpression[source]¶
Bases:
QgsMeshAdvancedEditing
- calculate(self, layer: QgsMeshLayer | None, project: QgsProject | None = None) bool [source]¶
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 does not apply new vertices to the mesh layer but only stores the calculated transformation that can be applied later with
QgsMeshEditor.advancedEdit()
- Parameters:
layer (Optional[QgsMeshLayer])
Added in version 3.44.
- Parameters:
project (Optional[QgsProject] = None)
- Return type:
bool
- setExpressions(self, expressionX: str | None, expressionY: str | None, expressionZ: str | None)[source]¶
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 (Optional[str])
expressionY (Optional[str])
expressionZ (Optional[str])
- setZFromTerrain(self, enable: bool)[source]¶
Sets if Z values for vertices should be obtained from project terrain, instead of expression.
Note
If
enable
is True, the Z value of the vertex will be obtained from the terrain of the project. The optional parameterproject
is necessary for function calculate (calculate()
).- Parameters:
enable (bool)
Added in version 3.44.
- transformedVertex(self, layer: QgsMeshLayer | None, vertexIndex: int) QgsPoint [source]¶
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 (Optional[QgsMeshLayer])
vertexIndex (int)
- Return type: