How to use a custom field with add_rewrite_rule()?

You should use ‘post_type_link’ hook

and register post type ‘project’ with (‘with_front’ => true) parameters

 'rewrite' => array('slug' => $slug, "with_front" => true),   

==================================or=====================================

add_rewrite_rule('^project/([0-9a-z]+)/?$', 'index.php?project=$matches[1]', 'top');

====================================================================

  function post_type_link_hook($link, $post) {
    add_rewrite_tag('%url_id%','([^&]+)');
    if ('projects' == get_post_type($post)) {
        $urlId = get_post_meta($post->ID, 'url_id', true);

        //Lets go to get the parent cartoon-series name
        return str_replace('%url_id%', $urlId, $link);
    }
    return $link;
   }
 add_filter('post_type_link', 'post_type_link_hook', 10, 2);