Option Explicit 'script to add (V-Ray) material to one layer 'copyright (©) 2013, Clement Greiner CG3D Call Main() Sub Main() ' layer Dim strLayer, arrIdx, arrM(), i, strMaterial, cmd ' check for materials arrIdx = Rhino.MaterialIndices() If Not IsArray(arrIdx) Then Rhino.Print "No materials found, load some materials first." Exit Sub End If ' choose layer strLayer = Rhino.GetLayer("Layer to assign material to",, True, True) If IsNull(strLayer) Then Exit Sub ' make array of material names ReDim arrM(UBound(arrIdx)) For i = 0 To UBound(arrIdx) : arrM(i) = Rhino.MaterialName(arrIdx(i)): Next ' choose material strMaterial = Rhino.ListBox(arrM, "Pick material to assign", "Materials") If IsNull(strMaterial) Then Exit Sub ' MsgBox strMaterial ' get material index ??? i = Rhino.MaterialIndex(strMaterial) ' assign to layer Call Rhino.LayerMaterialIndex(strLayer, 0) ' set layer to plugin cmd = "_-Layer _Material " & CHR(34) & strLayer & CHR(34) & " _Plugin " & CHR(34) & "V-Ray for Rhino" & CHR(34) & " _EnterEnd" Rhino.Command cmd End Sub