Error : Line 0 C# Rhino inside

I am trying to create a section of the graphical element that i select from revit. the dimension of section box is the bounding box of the element. I have written a C# code to create a section depending on the selected element, however i get an error of (line:0).
I am assuming is all the values of revitC# code are double and taking up lot of space.
Please provide some guidance for the code and error.
P.S. i am new to coding and trying to learn by making various codes.
Project1.rvt (408 KB) (18.5 KB)
Trail (18.4 KB)

Update : I am able to create sections now, however the orientation and location of section is in other direction can someone help me with that thank you.

Hi, I’m not seeing the transform aspect of the example in your code.

  // Using 0.5 and "true" to specify that the 
  // parameter is normalized places the transform
  // origin at the center of the location curve
  Transform curveTransform = lc.Curve
    .ComputeDerivatives( 0.5, true );
  // The transform contains the location curve
  // mid-point and tangent, and we can obtain
  // its normal in the XY plane:
  XYZ origin = curveTransform.Origin;
  XYZ viewdir = curveTransform.BasisX.Normalize();
  XYZ up = XYZ.BasisZ;
  XYZ right = up.CrossProduct( viewdir );
  // Set up view transform, assuming wall's "up" 
  // is vertical. For a non-vertical situation 
  // such as section through a sloped floor, the 
  // surface normal would be needed

Trial Updated with (16.4 KB)
So Japhy, i have updated the code with transform, there are two set of codes. The first one works but it works only in one direction. the second set of code is created using the data from the above mention code, however it gives me line:0 error can you have a look.