Object name to Text Object

Hi all!

Is there any way to create Text objects that automatically use the Object name? I’ve been trying to script this in Rhinoscript but nothing seems to work at this point. I’ve looked in Converting Text to Geometry with VBScript but my Rhinoscript does not recognize the object name strings as “Text” (by Rhino.IsText).

Example:

For Each strExtract In arrExtract
	
	If VarType(strExtract) = vbString Then
		objectname = sectienaam & " - " & newLayer & " " & a
		localname = Rhino.ObjectName(strExtract, objectname)		
	Else
		Rhino.Print("Object is not valid")
		Exit Sub
	End If
	
	a = a + 1 
	
	If Rhino.IsText(objectname) Then
		Rhino.Print("Is text")
	End If

Next

So “Is text” is not printed in this situation…

Thanks in advance!

Pim

Hi @pim_meester,

Have you tried just using text fields?

https://docs.mcneel.com/rhino/6/help/en-us/index.htm#information/text_fields.htm

– Dale

Hi Dale,

Thanks, I will look into Text Fields!

Pim

Just made something like this at a colleague’s request… I’m not very familiar with Rhinoscript and this could be improved for multiple objects, but at that point I’d probably say just use Grasshopper.

But this is basically just a quick way of applying the “Object Name” text field to a text object:

! -Runscript (
Call Main()
Sub Main()

Dim text : text = “%<objectname” & “(” & chr(34)
Dim sObj: sobj = Rhino.GetObject()
If isNull(sObj) Then Exit Sub
text = text & sobj & chr(34) & “)>%”

Dim arrPoint
arrPoint = Rhino.GetPoint(“Pick point”)
If IsArray(arrPoint) Then
Rhino.AddText text, arrPoint
End If

End Sub
)