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?
Rhino maintains annotation text in a CRhinoAnnotationText object, or MRhinoAnnotationText in .NET languages. You can retrieve the text string as follows:
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