def try_apply_relation_constraints(
    state: state_def.State, name: str, n_try_resolve=10, visualize=False
):
    """
    name is in objs.name
    name has been recently reassigned or added or swapped
    it needs snapping, and dof updates

    Result:
    dof_mat and dof axis for name are updated
    objstate for name has update location rotaton etc

    """

    validate_relations_feasible(state, name)

    for retry in range(n_try_resolve):
        obj_state = state.objs[name]
        if iu.blender_objs_from_names(obj_state.obj.name)[0].dimensions[2] > 2.5:
            logger.warning(
                f"Object {obj_state.obj.name} is too tall for the room: {obj_state.obj.dimensions[2]}, 2.5"
            )
        parent_planes = apply_relations_surfacesample(state, name)

        # assignments not valid
        if parent_planes is None:
            logger.debug(f"Found {parent_planes=} for {name=} {retry=}")
            if visualize:
                vis = butil.copy(obj_state.obj)
                vis.name = obj_state.obj.name[:30] + "_noneplanes_" + str(retry)
                butil.save_blend("test.blend")
            return False

        if validity.check_post_move_validity(state, name):
            obj_state.dof_matrix_translation = combined_stability_matrix(parent_planes)
            obj_state.dof_rotation_axis = combine_rotation_constraints(parent_planes)
            return True

        if visualize:
            vis = butil.copy(obj_state.obj)
            vis.name = obj_state.obj.name[:30] + "_failure_" + str(retry)
            butil.save_blend("test.blend")

    logger.debug(f"Exhausted {n_try_resolve=} tries for {name=}")
    return False

    name is in objs.name
    name has been recently reassigned or added or swapped
    it needs snapping, and dof updates

    Result:
    dof_mat and dof axis for name are updated
    objstate for name has update location rotaton etc

    
infinigen/core/constraints/example_solver/geometry/dof.py