Text entity problems /General C# question about Constructor

HI all,

I tried to use the Text entity to create text. So when I copy the example from the Rhino commons it works even if I get warnings that ‘Rhino.Geometry.AnnotationBase.Text’ ,Rhino.Geometry.AnnotationBase.FontIndex’ and: ‘Rhino.RhinoDoc.Fonts’ obsololete is.

The example code is that one:

 var text_entity = new TextEntity
      {
        Plane = plane,
        Text = text,
        Justification = TextJustification.MiddleCenter,
        FontIndex = doc.Fonts.FindOrCreate("Arial", false, false)
        };

    doc.Objects.AddText(text_entity);

Why doe it not work like this?


 var text_entity = new TextEntity(plane, text, TextJustification.MiddleCenter, doc.Fonts.FindOrCreate("Arial", false, false));

    doc.Objects.AddText(text_entity);

Now there is an error message about one obsolete methode(the .Fonts one), and it tells me there is no constructor taking just 4 arguments.

Maybe someone could explain me, would be nice.

Thanks!

The curly brackets are not an alternate notation for a constructor. They assign values to properties of the class. TextEntity only provides two constructors, an empty one (which you should use and which is implied in the first code) and a protected one for deserialization which you cannot use directly.

Thanks a lot David!