user: Show practical ways to work with Constraint(bpy_struct) in a Blender add-on or script – include code.

assistant: # Constraint(bpy_struct)

base class — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct")

subclasses —
[`ActionConstraint`](bpy.types.ActionConstraint.html#bpy.types.ActionConstraint "bpy.types.ActionConstraint"), [`ArmatureConstraint`](bpy.types.ArmatureConstraint.html#bpy.types.ArmatureConstraint "bpy.types.ArmatureConstraint"), [`CameraSolverConstraint`](bpy.types.CameraSolverConstraint.html#bpy.types.CameraSolverConstraint "bpy.types.CameraSolverConstraint"), [`ChildOfConstraint`](bpy.types.ChildOfConstraint.html#bpy.types.ChildOfConstraint "bpy.types.ChildOfConstraint"), [`ClampToConstraint`](bpy.types.ClampToConstraint.html#bpy.types.ClampToConstraint "bpy.types.ClampToConstraint"), [`CopyLocationConstraint`](bpy.types.CopyLocationConstraint.html#bpy.types.CopyLocationConstraint "bpy.types.CopyLocationConstraint"), [`CopyRotationConstraint`](bpy.types.CopyRotationConstraint.html#bpy.types.CopyRotationConstraint "bpy.types.CopyRotationConstraint"), [`CopyScaleConstraint`](bpy.types.CopyScaleConstraint.html#bpy.types.CopyScaleConstraint "bpy.types.CopyScaleConstraint"), [`CopyTransformsConstraint`](bpy.types.CopyTransformsConstraint.html#bpy.types.CopyTransformsConstraint "bpy.types.CopyTransformsConstraint"), [`DampedTrackConstraint`](bpy.types.DampedTrackConstraint.html#bpy.types.DampedTrackConstraint "bpy.types.DampedTrackConstraint"), [`FloorConstraint`](bpy.types.FloorConstraint.html#bpy.types.FloorConstraint "bpy.types.FloorConstraint"), [`FollowPathConstraint`](bpy.types.FollowPathConstraint.html#bpy.types.FollowPathConstraint "bpy.types.FollowPathConstraint"), [`FollowTrackConstraint`](bpy.types.FollowTrackConstraint.html#bpy.types.FollowTrackConstraint "bpy.types.FollowTrackConstraint"), [`GeometryAttributeConstraint`](bpy.types.GeometryAttributeConstraint.html#bpy.types.GeometryAttributeConstraint "bpy.types.GeometryAttributeConstraint"), [`KinematicConstraint`](bpy.types.KinematicConstraint.html#bpy.types.KinematicConstraint "bpy.types.KinematicConstraint"), [`LimitDistanceConstraint`](bpy.types.LimitDistanceConstraint.html#bpy.types.LimitDistanceConstraint "bpy.types.LimitDistanceConstraint"), [`LimitLocationConstraint`](bpy.types.LimitLocationConstraint.html#bpy.types.LimitLocationConstraint "bpy.types.LimitLocationConstraint"), [`LimitRotationConstraint`](bpy.types.LimitRotationConstraint.html#bpy.types.LimitRotationConstraint "bpy.types.LimitRotationConstraint"), [`LimitScaleConstraint`](bpy.types.LimitScaleConstraint.html#bpy.types.LimitScaleConstraint "bpy.types.LimitScaleConstraint"), [`LockedTrackConstraint`](bpy.types.LockedTrackConstraint.html#bpy.types.LockedTrackConstraint "bpy.types.LockedTrackConstraint"), [`MaintainVolumeConstraint`](bpy.types.MaintainVolumeConstraint.html#bpy.types.MaintainVolumeConstraint "bpy.types.MaintainVolumeConstraint"), [`ObjectSolverConstraint`](bpy.types.ObjectSolverConstraint.html#bpy.types.ObjectSolverConstraint "bpy.types.ObjectSolverConstraint"), [`PivotConstraint`](bpy.types.PivotConstraint.html#bpy.types.PivotConstraint "bpy.types.PivotConstraint"), [`ShrinkwrapConstraint`](bpy.types.ShrinkwrapConstraint.html#bpy.types.ShrinkwrapConstraint "bpy.types.ShrinkwrapConstraint"), [`SplineIKConstraint`](bpy.types.SplineIKConstraint.html#bpy.types.SplineIKConstraint "bpy.types.SplineIKConstraint"), [`StretchToConstraint`](bpy.types.StretchToConstraint.html#bpy.types.StretchToConstraint "bpy.types.StretchToConstraint"), [`TrackToConstraint`](bpy.types.TrackToConstraint.html#bpy.types.TrackToConstraint "bpy.types.TrackToConstraint"), [`TransformCacheConstraint`](bpy.types.TransformCacheConstraint.html#bpy.types.TransformCacheConstraint "bpy.types.TransformCacheConstraint"), [`TransformConstraint`](bpy.types.TransformConstraint.html#bpy.types.TransformConstraint "bpy.types.TransformConstraint")

*class* bpy.types.Constraint(*bpy_struct*)
:   Constraint modifying the transformation of objects and bones

    active
    :   Constraint is the one being edited

        Type:
        :   boolean, default False

    enabled
    :   Use the results of this constraint

        Type:
        :   boolean, default False

    error_location
    :   Amount of residual error in Blender space unit for constraints that work on position

        Type:
        :   float in [-inf, inf], default 0.0, (readonly)

    error_rotation
    :   Amount of residual error in radians for constraints that work on orientation

        Type:
        :   float in [-inf, inf], default 0.0, (readonly)

    influence
    :   Amount of influence constraint will have on the final solution

        Type:
        :   float in [0, 1], default 0.0

    is_override_data
    :   In a local override object, whether this constraint comes from the linked reference object, or is local to the override

        Type:
        :   boolean, default False, (readonly)

    is_valid
    :   Constraint has valid settings and can be evaluated

        Type:
        :   boolean, default False, (readonly)

    mute
    :   Enable/Disable Constraint

        Type:
        :   boolean, default False

    name
    :   Constraint name

        Type:
        :   string, default “”, (never None)

    owner_space
    :   Space that owner is evaluated in

        - `WORLD`
          World Space – The constraint is applied relative to the world coordinate system.
        - `CUSTOM`
          Custom Space – The constraint is applied in local space of a custom object/bone/vertex group.
        - `POSE`
          Pose Space – The constraint is applied in Pose Space, the object transformation is ignored.
        - `LOCAL_WITH_PARENT`
          Local With Parent – The constraint is applied relative to the rest pose local coordinate system of the bone, thus including the parent-induced transformation.
        - `LOCAL`
          Local Space – The constraint is applied relative to the local coordinate system of the object.

        Type:
        :   enum in [`'WORLD'`, `'CUSTOM'`, `'POSE'`, `'LOCAL_WITH_PARENT'`, `'LOCAL'`], default `'WORLD'`

    show_expanded
    :   Constraint’s panel is expanded in UI

        Type:
        :   boolean, default False

    space_object
    :   Object for Custom Space

        Type:
        :   [`Object`](bpy.types.Object.html#bpy.types.Object "bpy.types.Object")

    space_subtarget
    :   Armature bone, mesh or lattice vertex group, …

        Type:
        :   string, default “”, (never None)

    target_space
    :   Space that target is evaluated in

        - `WORLD`
          World Space – The transformation of the target is evaluated relative to the world coordinate system.
        - `CUSTOM`
          Custom Space – The transformation of the target is evaluated relative to a custom object/bone/vertex group.
        - `POSE`
          Pose Space – The transformation of the target is only evaluated in the Pose Space, the target armature object transformation is ignored.
        - `LOCAL_WITH_PARENT`
          Local With Parent – The transformation of the target bone is evaluated relative to its rest pose local coordinate system, thus including the parent-induced transformation.
        - `LOCAL`
          Local Space – The transformation of the target is evaluated relative to its local coordinate system.
        - `LOCAL_OWNER_ORIENT`
          Local Space (Owner Orientation) – The transformation of the target bone is evaluated relative to its local coordinate system, followed by a correction for the difference in target and owner rest pose orientations. When applied as local transform to the owner produces the same global motion as the target if the parents are still in rest pose..

        Type:
        :   enum in [`'WORLD'`, `'CUSTOM'`, `'POSE'`, `'LOCAL_WITH_PARENT'`, `'LOCAL'`, `'LOCAL_OWNER_ORIENT'`], default `'WORLD'`

    type
    :   Type:
        :   enum in [Constraint Type Items](bpy_types_enum_items/constraint_type_items.html#rna-enum-constraint-type-items), default `'CAMERA_SOLVER'`, (readonly)

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   [type](#bpy.types.Constraint.type "bpy.types.Constraint.type")