Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5804

Create instance of Public Method in RunScript error: C #

$
0
0

@brobes05 wrote:

Hi I am currently switching from Python to C# and am getting a fairly simple error ‘Method must have a return type error’. I have added the ‘Curve’ return type after the access modifer, but is causing more issues. Apologies for the amateur question. Thanks.

Here is the code:

private void RunScript(Curve profile, Curve path, int num, ref object A)
  {
    OrientCurves oCrv = new OrientCurves();
    A = oCrv;
  }

  // <Custom additional code> 

  public OrientCurves()
  {
    Plane basePlane = new Plane(profile.GetBoundingBox(false).Center, Vector3d.ZAxis);
    path.Domain = new Interval(0, 1);

    List<Curve> orientedCrv = new List<Curve>();
    List<Plane> perpFrames = new List<Plane>();

    for (int i = 0; i < num; i++)
    {
      Plane plane;

      path.PerpendicularFrameAt((double) i / num, out plane); 
      perpFrames.Add(plane);

      Curve newCrv = profile.DuplicateCurve(); //why duplicate curve??
      newCrv.Transform(Transform.PlaneToPlane(basePlane, plane));
      orientedCrv.Add(newCrv);

    }
    return orientedCrv; //this seems to be wrong
  }

}

methodError.gh (5.9 KB)

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 5804

Trending Articles