$mycategoryids = "345,366,456,444,789,345";
$cl->SetFilter( 'thecatid', array( $mycategoryids ));
Thats not valid code. You need to pass setFilter an array of numbers. Not an array containing a single string.
Both of these are better...
$mycategoryids = array(345,366,456,444,789,345);
$cl->SetFilter( 'thecatid', $mycategoryids);
or
$mycategoryids = "345,366,456,444,789,345";
$cl->SetFilter( 'thecatid', explode(',',$mycategoryids) );