Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5825

Compare 2 first characters of TextDotText

$
0
0

Hi,

I’m writting a simple Rhinoscript.
I would like to affect a layer (already in the document) to a DotText, based on the 2 first characters of the text inside the Dot…

Using the command Rhino.TextDotText(), I have can have the text easily, but then I can’t find a way to compare only the 2 first characters.

There will always be 7 characters, but the 4 last are numbers that are variable.
This is the 2 first character that will define the Dot’s layer.

For now, the script works with the exact Dot text, taking 1000 as a variable :

Dim Selection
Selection = rhino.SelectedObjects
If IsNull(Selection) Then
	Selection = Rhino.GetObjects("Selectionner les DOT", 8192)
End If
For x = 0 To ubound(Selection)
	If Rhino.IsTextDot(Selection(x)) Then
		If Rhino.TextDotText(Selection(x)) = "ST_1000" Then
			Rhino.ObjectLayer Selection(x), "Acier"
		ElseIf	Rhino.TextDotText(Selection(x)) = "BO_1000" Then
			Rhino.ObjectLayer Selection(x), "Boulonnerie"
		ElseIf	Rhino.TextDotText(Selection(x)) = "GL_1000" Then
			Rhino.ObjectLayer Selection(x), "Bois"
		ElseIf	Rhino.TextDotText(Selection(x)) = "CA_1000" Then
			Rhino.ObjectLayer Selection(x), "Cables"
		ElseIf	Rhino.TextDotText(Selection(x)) = "AS_1000" Then
			Rhino.ObjectLayer Selection(x), "Profils aluminium"
		Else 
			Rhino.ObjectLayer Selection(x), "Divers"
		End If
	End If
Next

Any tips ?
Thanks

Test.3dm (311.5 KB)

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5825

Trending Articles