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

Modify material names in RhinoScript

$
0
0

I used “Rhino.MaterialName” method in RhinoScript to modify the material names. Those changes shows up in layer panel, but not in material editor. And when I save and reopen the file. All changes are gone.

Here is my code:

`
Sub AddPrefixToAllMaterials()
	Dim arrMaterials, strMaterial, intIndex, strNewName, strPrefix

	arrMaterials = Rhino.MaterialIds
	strPrefix = Rhino.GetString("Prefix to add")
	

	If IsArray(arrMaterials) Then

		For Each strMaterial In arrMaterials
			intIndex = Rhino.MaterialIndex(strMaterial)
			strNewName = strPrefix + Rhino.MaterialName(intIndex)
			
			If IsNull(strPrefix) Then
				Rhino.Print("NewName is Null")						
			Else
				Rhino.Print(strNewName)
				Rhino.MaterialName intIndex, strNewName
			End If
		
		Next
		
	End If
	
End Sub


Can somebody help? Thank you!

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5808

Trending Articles