Class: QgsCadUtils

Provides routines for CAD editing.

Static Methods

alignMapPoint

Applies X/Y/angle/distance constraints from the given context to a map point.

class qgis.core.QgsCadUtils[source]

Bases: object

class AlignMapPointConstraint[source]

Bases: object

Structure with details of one constraint.

QgsCadUtils.AlignMapPointConstraint(locked: bool = False, relative: bool = False, value: float = 0) Constructor for AlignMapPointConstraint.

QgsCadUtils.AlignMapPointConstraint(a0: QgsCadUtils.AlignMapPointConstraint)

locked: bool

Whether the constraint is active, i.e. should be considered

relative: bool

Whether the value is relative to previous value

value: float

Numeric value of the constraint (coordinate/distance in map units or angle in degrees)

class AlignMapPointContext[source]

Bases: object

Defines constraints for the QgsCadUtils.alignMapPoint() method.

angleConstraint: AlignMapPointConstraint

Constraint for angle

cadPoint(self, index: int) QgsPoint[source]

Returns the recent CAD point at the specified index (in map coordinates).

See also

setCadPoint()

Added in version 3.22.

Parameters:

index (int)

Return type:

QgsPoint

property cadPointList
Return type:

List[QgsPointXY]

cadPoints(self) List[QgsPoint]

Returns the list of recent CAD points in map coordinates.

These are used to turn relative constraints to absolute. The first point is the most recent point.

See also

setCadPoints()

Added in version 3.22.

Return type:

List[QgsPoint]

commonAngleConstraint: AlignMapPointConstraint

Constraint for soft lock to a common angle

distanceConstraint: AlignMapPointConstraint

Constraint for distance

lineExtensionConstraint
mConstraint: AlignMapPointConstraint

Constraint for M coordinate

Added in version 3.22.

mapUnitsPerPixel: float

Map units/pixel ratio from map canvas.

setCadPoint(self, index: int, point: QgsPoint)[source]

Sets the recent CAD point at the specified index to point (in map coordinates).

See also

cadPoint()

Added in version 3.22.

Parameters:
setCadPoints(self, points: Iterable[QgsPoint])[source]

Sets the list of recent CAD points (in map coordinates).

See also

cadPoints()

Added in version 3.22.

Parameters:

points (Iterable[QgsPoint])

snappingToFeaturesOverridesCommonAngle: bool

Flag to set snapping to features priority over common angle.

Added in version 3.32.

snappingUtils: QgsSnappingUtils

Snapping utils that will be used to snap point to map. Must not be None.

xConstraint: AlignMapPointConstraint

Constraint for X coordinate

xyVertexConstraint
yConstraint: AlignMapPointConstraint

Constraint for Y coordinate

zConstraint: AlignMapPointConstraint

Constraint for Z coordinate

Added in version 3.22.

class AlignMapPointOutput[source]

Bases: object

Structure returned from alignMapPoint() method.

edgeMatch: Match

Snapped segment - only valid if actually used for something

Deprecated since version 3.40: Will be removed in QGIS 4.0 - use snapMatch() instead.

finalMapPoint: QgsPointXY

map point aligned according to the constraints

snapMatch: Match

Snapped point - only valid if actually used for something

Added in version 3.14.

softLockCommonAngle: float

Angle (in degrees) to which we have soft-locked ourselves (if not set it is -1)

softLockLineExtension
softLockX
softLockY
valid: bool

Whether the combination of constraints is actually valid

static alignMapPoint(originalMapPoint: QgsPointXY, ctx: QgsCadUtils.AlignMapPointContext) QgsCadUtils.AlignMapPointOutput[source]

Applies X/Y/angle/distance constraints from the given context to a map point. Returns a structure containing aligned map point, whether the constraints are valid and some extra information.

Parameters:
Return type:

QgsCadUtils.AlignMapPointOutput