Slicing brep - For some input values python doesn't output intersected brep (null). For other values it works fine!

I am trying to create slices out of a brep by intersecting it with an array of planes, using GhPython component. It works for some ranges of input values. But for others, it throws out: “Parameter must be a Guid or string representing a Guid” And the output is null (no geometry).

Here are some shots showing how it behaves for certain values. There are different input parameters and this problem occurs for some of their values:

And this is the code:

I can’t figure out what is going on there… Why does it work with certain values and not with a set of others?

Update: Also if the control points are moved in the Z direction to increase the size of the input brep, it disappears again (i.e., same error occurs as changing some values). Moving the control-points along X or Y directions doesn’t cause any problem though.

It should give you the line number causing the problem together with the error message …?

The error is:

Parameter must be a Guid or string representing a Guid

The line no. referring to the script in the error output are 45, 55.
Line no. 45:
brepExtruded = rs.ExtrudeCurve(brepResult, extrVect)
Line no. 55 (function call):
createSlices(nZ, xTmp, y1, y2, zTmp, plnXY, extrVectZ, z)

And some line no.s of rhino application’s python scripts, such as,

Here’s a shot of the error output:

I tried removing line 55, (2nd call to the function, slicing along the Z-axis), and it does reduce the error producing ranges of input values. So in this case,
all the values of ‘d’ (dist b/w slices) run valid;
‘w’ values run valid from 1.51 and above, but 1.50 and below throw error;
‘h’ values run valid from 1.31 and above, but 1.30 and below throw the same error.

I feel it is the rs.ExtrudeCurve on the resultant intersections that is having problems… Why would the ‘parameters’ not be a ‘Guid’ (or a string representing that), for certain values?

I tried removing the extrusion part from the function so that the resultant is just the set of planes (in both X and Z directions), and it works for all values.
Here is the edited function (I was just testing and have not cleaned it up totally, so ‘extrVect’ is redundant here):

So why is rs.ExtrudeCurve having problems with certain values?