Sdk Get Text
Last changed: dale@mcneel.com-204.177.179.95

.
Developer.NET
VersionRhino 4.0
SummaryDemonstrates how to retrieve the text string from an annotation text object using the Rhino 4.0 SDK.

Question

If I have added annotation text to a model using Rhino's Text command or RhinoScript's AddText method, how can I retrieve the string using the SDK?

Answer

Rhino maintains annotation text in a CRhinoAnnotationText object, or MRhinoAnnotationText in .NET languages. You can retrieve the text string as follows:

VB.NET

  Public Overrides Function RunCommand(ByVal context As RMA.Rhino.IRhinoCommandContext) _ 
          As RMA.Rhino.IRhinoCommand.result


    Dim go As New MRhinoGetObject
    go.SetCommandPrompt("Select annotation text")
    go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.annotation_object)
    go.GetObjects(1, 1)
    If (go.CommandResult() <> IRhinoCommand.result.success) Then
      Return go.CommandResult()
    End If


    Dim annotation_obj As IRhinoAnnotationText = MRhinoAnnotationText.ConstCast(go.Object(0).Object())
    If (annotation_obj Is Nothing) Then
      RhUtil.RhinoApp().Print("Not an annotation text object." + vbCrLf)
    End If


    Dim str As String = annotation_obj.String()
    RhUtil.RhinoApp().Print(String.Format("Annotation text = {0}" + vbCrLf, str))
    Return IRhinoCommand.result.success


  End Function