Building a view programmatically fails when filtering specific nids but not others
The argument to the $views-&gt;set_arguments() function should be an array containing the arguments, even if only one, so, try:

$view-&gt;set_arguments(array(35));


or

$view-&gt;set_arguments(array($nid));


instead of passing the value in directly.

As to why it was working before sometimes, I am betting it was working with nids 1 thru 9 only, because there, for example, if $nid='4', $nid[0]=='4' is also true, but if $nid='35', $nid[0]=='35' is false (it is '3') but I leave this to another discussion, but look up "php strings as arrays" if you want to delve into it further.  This Strings as Arrays Q&amp;A gives a brief description/introduction.