Click or drag to resize

ObjectTableAddText Method (String, Plane, Double, String, Boolean, Boolean)

Adds an annotation text object to the document.

Namespace:  Rhino.DocObjects.Tables
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax
public Guid AddText(
	string text,
	Plane plane,
	double height,
	string fontName,
	bool bold,
	bool italic
)

Parameters

text
Type: SystemString
Text string.
plane
Type: Rhino.GeometryPlane
Plane of text.
height
Type: SystemDouble
Height of text.
fontName
Type: SystemString
Name of FontFace.
bold
Type: SystemBoolean
Bold flag.
italic
Type: SystemBoolean
Italic flag.

Return Value

Type: Guid
The Guid of the newly added object or Guid.Empty on failure.
Examples
using System;

partial class Examples
{
  public static Rhino.Commands.Result AddAnnotationText(Rhino.RhinoDoc doc)
  {
    Rhino.Geometry.Point3d pt = new Rhino.Geometry.Point3d(10, 0, 0);
    const string text = "Hello RhinoCommon";
    const double height = 2.0;
    const string font = "Arial";
    Rhino.Geometry.Plane plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane();
    plane.Origin = pt;
    Guid id = doc.Objects.AddText(text, plane, height, font, false, false);
    if( id != Guid.Empty )
    {
      doc.Views.Redraw();
      return Rhino.Commands.Result.Success;
    }
    return Rhino.Commands.Result.Failure;
  }
}
Python
import Rhino
import scriptcontext
import System.Guid

def AddAnnotationText():
    pt = Rhino.Geometry.Point3d(10, 0, 0)
    text = "Hello RhinoCommon"
    height = 2.0
    font = "Arial"
    plane = scriptcontext.doc.Views.ActiveView.ActiveViewport.ConstructionPlane()
    plane.Origin = pt
    id = scriptcontext.doc.Objects.AddText(text, plane, height, font, False, False)
    if id!=System.Guid.Empty:
        scriptcontext.doc.Views.Redraw()
        return Rhino.Commands.Result.Success
    return Rhino.Commands.Result.Failure


if __name__=="__main__":
    AddAnnotationText()
See Also