Rhino on large-scale project #2: Scripting to batch files

Although we have mentioned the “worksession” in the previous article, we introduced the usage to collaborate by splitting the model into multiple files.

This post is to routinize the workflow by splitting the file into several units parts.

Using this method, you can avoid the condition ” This file is too heavy to make anything! “

Imagine a panelized facade model.

Let’s consider the case that divided facade panels are made from a single surface.

Creating the files by dividing them as each panel files with the “Export” component in EleFront.

It works.

Please think of the units of split files as for a part drawing. (fabrication drawing)

Next, let’s work on panel-by-panel.

Suppose that you need to “Make the dots on the rectangle four corners, 100mm from the edge”.

Let’s start this operation (assuming the dots were the base points of the fasteners).

You will start from GH for a single panel.

In the end, bake with the ” Attribute User Text” setting as the attached picture.

The key point is to use the components, ” Reference by Layer” and “Bake”, of EleFront.

You need to take additional care of the setting of the RefLay.

By AutoUpdate, the GH will bake every time when Rhino opens a model.

From now, here is the highlight.

Using some kind of scripts, to run the following orders for all 3dm files in the working folder.




#Assuming utf-8 to support Japanese(or English) names
# -*- coding: utf-8 -*-

#Normal setting
import os
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

#To target the currently open Rhino file
sc.doc = Rhino.RhinoDoc.ActiveDoc 

mydir = rs.BrowseForFolder(None,"Sel Folder")

##List the paths of Rhino files in the folder
def getRhinoFile(dir):
    pathList = []
    for file in os.listdir(dir):
        if file.endswith(".3dm"):
            path = dir + "\\" + file
            print (path)
    return (pathList)

#Open the file with the specified path and save ..
def open_close(dir):
    for f in dir:
        f = '"' + f + '"'
        rs.Command("_-Open {}".format(f))

#File acquisition
files = getRhinoFile(mydir)
#Loop the "open" and "save" order

It may be confusing to see only the script.

You can apply a GH to multiple files, combining with the script.

It might be hard to see the effect if you do some simple operations or the quantity is small.

When the number of parts exceeds 1000, the Rhino might crash without this kind of process.

Please try it when you need to make a huge model.

Translation: Iris Huang


Mainly working on façade and parametric modeling. Previously worked as an architectural designer at AEC firm. Write about complex geometry and model with information from CMr / PMr viewpoint.


Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment