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

Importing layers via Rhino.FileIO

$
0
0

@Helvetosaur wrote:

Hi there,

I’m toying around with an “import layers from file” function. I am able to successfully import layers (including tree hierarchy, which is good) using the following code:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def ImportLayersFromFileTest():
    filename=rs.OpenFileName("Choose file to import layers")
    if not filename: return
    #optional, doesn't change much
    #tbl_filt=Rhino.FileIO.File3dm.TableTypeFilter.None
    #no_obj=Rhino.FileIO.File3dm.ObjectTypeFilter.None
    #read_file=Rhino.FileIO.File3dm.Read(filename,tbl_filt,no_obj)
    read_file=Rhino.FileIO.File3dm.Read(filename)
    if read_file:
        layer_list=read_file.AllLayers
        for layer in layer_list:
            sc.doc.Layers.Add(layer)

ImportLayersFromFileTest()

This does work to import the layer arrangement without objects, which is what I want. But, some of the layer characteristics are not imported - notably the layer material assignment if any the linetype. OTOH, layer print color and print width are imported.

So the question is this: is there some easy trick I’m missing or do I also need to get the material table separately, add the materials to the file if they do not already exist, and then re-assign them to the imported layers? Same for the linetypes?

I also understand that I will need to do some checking for existing layers and possible conflict resolution, but that’s for later…

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles