Align objects with a 3d curve - pt 3

Hi,

I am currently looking at using Dynamo to create a geometry (along a S-shaped nurbs curve) that rotates along its longitudinal axis. However, I have the issue of no consistent orientation of the X and Y axes of
the planes due to Curve.PlaneAtParameter.

I have read the following thread (
http://dynamobim.com/forums/topic/align-objects-with-a-3d-curve/) which covers a similar problem; Dimitar Venkov posted a possible solution to my problem on July 27, 2015. However I believe that the Vector.AngleBetween node has been superseded in later releases of Dynamo and I am now using Vector.AngleWithVector node. The revised definition (see below) however is giving an error message “Error: Invalid imperative_assignstmt”. Does anyone have an idea as how to resolve this issue?

[fyi I am using Dynamo Studio 1.2.0…2871. I also tried using Dynamo 1.2.1 in Revit but same issue]

def RvtAngleAtParam(crv, par)
{
t1 = crv.TangentAtParameter(par);
vx = t1.X;
vy = t1.Y;
alpha = t1.AngleWithVector(Vector.XAxis());
return = [Imperative]
{
if (vx >= 0 && vy >= 0)
{
return = – alpha;
}
elseif (vx < 0 && vy < 0)
{
return = – alpha;
}
elseif (vx >= 0 && vy < 0)
{
return = alpha;
}
else
{
return = alpha;
}
}
};