Transfer Layer Properties

This tool takes the Layer Color, Print Width, Line Type, and Print Color from a user selected set of layers and exports them along with the corresponding layer names to a RLF (Rhino Layer Format) file, which can be opened in any text editor. This file can be loaded into another rhino session and all layers with the corresponding names will be updated to match the properties of the layers from the source file. This makes it simple to match appearance from one file to the next.

The command works as follows

  • Run the command TransferLayerProperties in the Rhino command line
  • Toggle between Export and Import
  • Select the Layers to either read from or override
  • Select the File path for importing or exporting

The rhino script can be directly copied from below and the and downloadable rhino plugin contains the command.

Rhino Script

Option Explicit 
'Script written by <David Mans> 
'Script copyrighted by <NeoArchaic || Grimshaw Architects> 
'Script version Tuesday, 08 December 2015 12:15:08 
Call Main() 
Sub Main() 
Dim Status 
Status = Rhino.GetBoolean("Import or Export", array("Type", "Import", "Export"), array(True)) 
If (IsNull(Status)) Then Exit Sub 
Dim i,j,k 
Dim File 
Dim Lyrs 
If Status(0) Then 
Lyrs = Rhino.GetLayers("Select Layers to Export", False) 
If (IsNull(Lyrs)) Then Exit Sub 
Dim Lines() 
ReDim Lines((ubound(Lyrs)+1)*5-1) 
For i = 0 To ubound(Lyrs) Step 1 
Dim Name, Lcolor, Ptype, Pcolor, Pwidth 
Name = Rhino.LayerName(Lyrs(i), False) 
Lcolor = Rhino.LayerColor(Lyrs(i)) 
Ptype = Rhino.LayerLinetype(Lyrs(i)) 
Pcolor = Rhino.LayerPrintColor(Lyrs(i)) 
Pwidth = Rhino.LayerPrintWidth(Lyrs(i)) Lines(i * 5 + 0) = cstr(Name) 
Lines(i * 5 + 1) = cstr(Lcolor) 
Lines(i * 5 + 2) = cstr(Ptype) 
Lines(i * 5 + 3) = cstr(Pcolor) 
Lines(i * 5 + 4) = cstr(Pwidth) 
File = Rhino.SaveFileName("Save", "Text Files (*.RLF)|*.rlf",,, "Text Files (*.RLF)|*.rlf") 
If (IsNull(File)) Then Exit Sub 
Call Rhino.WriteTextFile(File, Lines, False) Else 'OPTION FOR IMPORTING 
File = Rhino.OpenFileName("Open", "Text Files (*.RLF)|*.rlf") 
If (IsNull(File)) Then Exit Sub 
Dim Txt Txt = Rhino.ReadtextFile(file, False, False) 
If (IsNull(Txt)) Then Exit Sub 
Dim Names, Lcolors, Ptypess, Pcolors, Pwidths 
k = (ubound(Txt) + 1) / 5 
ReDim Lcolors(k-1) 
ReDim Ptypess(k-1) 
ReDim Pcolors(k-1) 
ReDim Pwidths(k-1) 
Set Names = CreateObject("Scripting.Dictionary") 
For i = 0 To k - 1 Step 1 
If Not Names.Exists(cstr(Txt(i * 5 + 0))) Then 
Names.add cstr(Txt(i * 5 + 0)), cstr(i) 
End If 
Lcolors(i) = Txt(i * 5 + 1) 
Ptypess(i) = Txt(i * 5 + 2) 
Pcolors(i) = Txt(i * 5 + 3) 
Pwidths(i) = Txt(i * 5 + 4) 
Lyrs = Rhino.GetLayers("Select Layers to Override", False) 
If (IsNull(Lyrs)) Then Exit Sub 
For i = 0 To ubound(Lyrs) Step 1 
Dim Current, FullName 
Current = Rhino.LayerName(Lyrs(i), False) 
If Names.Exists(Current) Then 
j = int(Names.item(Current)) 
Call Rhino.LayerColor(Lyrs(i), int(Lcolors(j))) 
Call Rhino.LayerLinetype(Lyrs(i), cstr(Ptypess(j))) 
Call Rhino.LayerPrintColor(Lyrs(i), int(Pcolors(j))) 
Call Rhino.LayerPrintWidth(Lyrs(i), cdbl(Pwidths(j))) 
End If 
End If 
End Sub