Using special characters in RhinoScript

Hi there,

I’m new in scripting with RhinoScript.
I want to change the layer of an object (TextDotObject)
But the layer I want to use is named “MON>Repères Acier” #France
There is an accent in the name of the layer.
I don’t want to modify the layer’s name, because it would mean changes in the general process of the company.

Is there any way to make Rhino understand the name of the layer while keeping the accent ?

Thanks !

Are you using Python? To be able to use non-ASCII characters as strings in a Python script you need to put the following at the top of the script to allow Unicode UTF 8 encoding (which accepts accented characters):

#!/usr/bin/env python
# -*- coding: utf-8 -*-
1 Like

No unfortunately, RhinoScript is a scripting tool based on Microsoft’s VBScript language.
Here’s how it looks :

Your script seems to work here in VB Rhinoscript… What’s not working for you?

Option Explicit

Call Main()
Sub Main()	
	Dim arrObject
	arrObject = Rhino.GetObject("Select text dot", 8192)
	If Not IsNull(arrObject) Then
		Rhino.ObjectLayer arrObject, "Mon>Repères Acier"
	End If
End Sub

Test-Repères.3dm (2.1 MB)

En theory, but if I keep the accent in the new layer name “MON>Repères Acier”, it does not work, nothing happens…
But if I remove the accent from the script and the layer name, the script works…
Sounds possible ?

As I said, it works here on the Rhino file I posted above with the layer name. It also works if I try to add the layer (with accent) via Rhinoscript:

Option Explicit

Call Main()
Sub Main()
	Dim strLayer, arrObject
	strLayer = "Mon>Repères Acier"
	
	If Not Rhino.IsLayer(strLayer) Then
		Rhino.AddLayer strLayer
	End If
	
	
	arrObject = Rhino.GetObject("Select text dot", 8192)
	If Not IsNull(arrObject) Then
		Rhino.ObjectLayer arrObject, strLayer
	End If
	
End Sub

Indeed it works…
My bad, I must have made an error…

Thanks Helvetosaur,
I’ll close the subject !