Finding curve's degree using C#


#1

Hi everyone,

I was checking this link http://www.grasshopper3d.com/forum/topics/curve-degree

and I tried to do the same

    using Rhino.Geometry.Curve;

    //Curve degree
    if(x != null)
      A = degreeCurve;

but I got this message

´´´
Error (CS1003): Syntax error, ‘(’ expected (line 70)
Error (CS1026): ) expected (line 70)

´´´

Can someone tell me what I´m doing wrong !!!

Thank you in advance


(Dale Fugier) #2

Hi @Nader_Belal,

Use Curve.Degree.

– Dale


#3

How ??


(Dale Fugier) #4

Try this from a command:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  ObjRef obj_ref;
  var rc = Rhino.Input.RhinoGet.GetOneObject("Select curve", false, ObjectType.Curve, out obj_ref);
  if (rc == Result.Success)
  {
    var curve = obj_ref.Curve();
    if (null != curve)
      RhinoApp.WriteLine("Curve degree = {0}", curve.Degree);
  }
  return rc;
}

– Dale


#6

@dale

Sorry for being a noob in C#, but I don’t get the idea how or where I should put that script.

@Baris
Your pic have helped me to reach my goal, sorry if it got deleted, anyway I have flagged it asking the moderators to keep it.

@ All
By pure accident, this is what have functioned with my case.

A = x.Degree;

Now the important question, why the editor didn’t recognised “Crv” nor “Curve” ??? That have baffled me.

And thank you all


(Michael Pryor) #7

because you didnt make a curve named Crv or Curve. Your curve is most likely named x.


#8

Actually, I have copied and pasted the example that I have mentioned in the quetion at the top of the thread


(Michael Pryor) #9

Yea, the curves name there is x.


#10

Sorry, my bad