""" ========================================================= -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Title: Rhino Layer State Batch Render -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- ========================================================= -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Author: Vlad -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Description: The Script renders all the named views with and goes through all the layer states -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- Notes: The folder destination, layerstate name, & view names must be clear of characters which cannot be part of a file's name (i.e. Tilde (~) Number sign (#) Percent (%) Ampersand (&) Asterisk (*) Braces ({ }) Backslash (\) Colon (:) Angle brackets (< >) Question mark (?) Slash (/) Plus sign (+) Pipe (|) Quotation mark (") -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- ========================================================= """ import rhinoscriptsyntax as rs import scriptcontext as sc import sys import Rhino def ChangeLayerState(LayerState): """ Receives a LayerState and changes the model to that specific LayerState """ plugin = rs.GetPlugInObject("Rhino Bonus Tools") if plugin is not None: plugin.RestoreLayerState(LayerState, 0) return 1 else : return 0 def GetLayers(): return Rhino.LayerNames def GetLayerStates(): """ The function returns the LayerStates that can be found in the model """ plugin = rs.GetPlugInObject("Rhino Bonus Tools") if plugin is not None: MyArray = plugin.LayerStateNames MyArrayB = [] MyArray = str(MyArray[1]) Trigger = True while (Trigger): poz=MyArray.rfind("'") MyArray = MyArray[:poz] poz=MyArray.rfind("'") dif = MyArray[poz:] dif = dif[1:] MyArrayB.append(dif) MyArray = MyArray[:poz] if len(MyArray)<14: Trigger = False del MyArrayB[-1] #clean up the list return MyArrayB if __name__ == "__main__": count = 0 layer_names = rs.LayerNames() newDefaultLayer = 'NewDefault' rs.AddLayer(newDefaultLayer) rs.CurrentLayer(newDefaultLayer) for l in layer_names: if rs.IsLayer(l): rs.LayerVisible(l, False) else: print "The layer does not exist." for l in layer_names: if l != newDefaultLayer: rs.LayerVisible(l, True) rs.Sleep(200) rs.LayerVisible(l, False) rs.DeleteLayer(newDefaultLayer)