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
}
If you want it to be a method you have to add the type in the initial declaration. Note you have to add the inputs inside the initial () after the declaration.
@felipegutierrezduque that’s what I thought and tried. When I add what you suggest, I am getting more errors. Clearly I am not understanding some basic method functionality.
Your are defining a Curve method but you are returning a List of Curve. And num is not declared as an input so there is no way that the OrientCurves method knows what num means.
line 57 is so wrong. You initiate a class which you never created, you defining a method below so you need to call it like method. This is not so much different to Python actually, which indicates you may missing basic knowledge about coding. I would advice to actually walk through basics before actually trying to implement a concrete functionality.