Forgot password?

Create an account!


« back

RhinoScript – Generate Layers from Filenames


Please log in to write a message.

  • 3. rubenruckman (Oct 29, 2014 22.54):

    This script prompts you to choose IGS files, then dumps the joined surfaces onto a layer that uses the IGES's filename. Should help your import process:

    Option Explicit
    Call ImportBatchFiles()

    Sub ImportBatchFiles()
            Dim arrFileNames, strFileName, strObject, i, newLayer, strPath, arrObjects

            arrFileNames = Rhino.OpenFileNames("Open", "IGS (*.igs)|*.igs|All Files (*.*)|*.*||")

            If IsArray(arrFileNames) Then

                    For Each strFileName In arrFileNames

                            'Import IGS
                            Rhino.Command "_Import """ + strFileName + """"

                            'Retrieve File Path
                            strObject = strFileName
                            strPath = Rhino.DocumentPath
                            'Clean up FileName
                            'Remove parts that we don't want to turn into layers
                            strObject = Replace(strObject, strPath, "")
                            strObject = Replace(strObject, ".igs", "")

                            'Create new Layer
                            newLayer = Rhino.AddLayer(strObject)
                            'Move joined igs objects to the layer created
                            Rhino.ObjectLayer Rhino.JoinSurfaces(Rhino.LastCreatedObjects, True), newLayer


            End If

    End Sub
  • 2. Johannes (Oct 16, 2014 13.31):

    Hi, i have an old script that reads filenames from a specific folder...

    Dim objFSO, objFolder
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Dim objStartFolder      : objStartFolder = "C:\TEST"

    Set objFolder = objFSO.GetFolder(objStartFolder)

    Call GenerateLayersFromFilenames(objStartFolder)

    Function GenerateLayersFromFilenames(Folder)
            Dim oFile, strFile
            For Each oFile In objFSO.GetFolder(Folder).Files
                    strFile = oFile.Name
                    Call Rhino.AddLayer(strFile)

    End Function


  • 1. jacobgerlach (Oct 14, 2014 18.18):


    I have a tedious IGES import process to deal with, and just discovered RhinoScript. I have no RhinoScript experience!

    I'd like to automate the following sequence:
    Import iges geometry
    'Join' the imported geometry
    Create a new layer containing the joined geometry. Name the layer with the base file name.

    for files in directory
    base=(file - .iges)

    Any pointers on how to approach this would be greatly appreciated!


Why are these buttons gray?