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

Made a script that's running every time I open rhino... what gives?

$
0
0

@wynott wrote:

This is probably obvious... Used the same sortof beginning lines as usual but first time I've had a problem:

Option Explicit
'Script written by Ryan Wynott
'Script version November 25, 2016 9:55:46 AM

Rhino.AddStartupScript Rhino.LastLoadedScriptFile()
Rhino.AddAlias "RenameToMaterials", "_NoEcho _-Runscript (RenameToMaterials)"

Call RenameToMaterials()
Sub RenameToMaterials()

Dim arrObjects, strObject
arrObjects = Rhino.ObjectsByType(8 + 16 + 32)

For Each strObject In arrObjects

	Dim strObjectLayer: strObjectLayer = Rhino.ObjectLayer(strObject)

	Dim materialIndex: materialIndex = Rhino.LayerMaterialIndex(strObjectLayer)

	If materialIndex = -1 Then

		Rhino.Print "The object layer does not have a material assigned."

	Else
		Dim objectMaterial: objectMaterial = Rhino.MaterialName(materialIndex)

		Rhino.ObjectName strObject, objectMaterial

		Rhino.Print objectMaterial
		Rhino.Print "renamed object"

	End If

Next

End Sub

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5783

Trending Articles