ObjectTableAddText Method (Text3d) |
Adds an annotation text object to the document.
Namespace:
Rhino.DocObjects.Tables
Assembly:
RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax public Guid AddText(
Text3d text3d
)
Public Function AddText (
text3d As Text3d
) As Guid
Parameters
- text3d
- Type: Rhino.DisplayText3d
The text object to add.
Return Value
Type:
GuidThe Guid of the newly added object or Guid.Empty on failure.
Examples using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
namespace examples_cs
{
public class TextJustifyCommand : Command
{
public override string EnglishName { get { return "csTextJustify"; } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var text_entity = new TextEntity
{
Plane = Plane.WorldXY,
PlainText = "Hello Rhino!",
Justification = TextJustification.MiddleCenter,
Font = doc.Fonts.FromQuartetProperties("Arial", false, false)
};
doc.Objects.AddText(text_entity);
doc.Views.Redraw();
return Result.Success;
}
}
}
Imports Rhino
Imports Rhino.Commands
Imports Rhino.Geometry
Namespace examples_vb
Public Class TextJustifyCommand
Inherits Command
Public Overrides ReadOnly Property EnglishName() As String
Get
Return "vbTextJustify"
End Get
End Property
Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
Dim text_entity = New TextEntity()
text_entity.Plane = Plane.WorldXY
text_entity.PlainText = "Hello Rhino!"
text_entity.Justification = TextJustification.MiddleCenter
text_entity.Font = doc.Fonts.FromQuartetProperties("Arial", False, False)
doc.Objects.AddText(text_entity)
doc.Views.Redraw()
Return Result.Success
End Function
End Class
End Namespace
from scriptcontext import doc
from Rhino.Geometry import *
text_entity = TextEntity()
text_entity.Plane = Plane.WorldXY
text_entity.PlainText = "Hello Rhino!"
text_entity.Justification = TextJustification.MiddleCenter
text_entity.Font = doc.Fonts.FromQuartetProperties("Arial", False, False)
doc.Objects.AddText(text_entity)
doc.Views.Redraw()
See Also