Example #1
0
def readNodes():
    path = rs.WorkingFolder()
    filename = rip.RhinoGet.GetFileName(ric.GetFileNameMode.OpenTextFile, "*",
                                        "select file", None)

    with open(filename, "r") as f:
        for _ in range(1):  #skip first 1 lines
            next(f)
        for line in f:
            dataTMP = (line.split(" "))
            data = dataTMP[2].split(",")
            if (len(data) == 8):
                indxList = [
                    int(data[0]),
                    int(data[1]),
                    int(data[2]),
                    int(data[3]),
                    int(data[4]),
                    int(data[5]),
                    int(data[6]),
                    int(data[7])
                ]
                state = int(dataTMP[4])
                nid = str(dataTMP[0])
                nodesList.append(node(indxList, state, nid))
        f.close()
    print(len(nodesList))
def objBatchExport():
    selection = rs.GetObjects(preselect=True)
    folder = rs.BrowseForFolder(rs.WorkingFolder())

    rs.EnableRedraw(False)
    for i, obj in enumerate(selection):
        e_file_name = "{}-{}.obj".format("habibi", i)
        rs.UnselectAllObjects()
        rs.SelectObject(obj)
        rs.Command('-_Export "{}" _Enter'.format(e_file_name), True)
    rs.EnableRedraw(True)
Example #3
0
def readPts():
    path = rs.WorkingFolder()
    #filename=rip.RhinoGet.GetFileName(ric.GetFileNameMode.OpenTextFile, "*", "select file",None)
    filename = "../constant/polyMesh/points"
    with open(filename, "r") as f:
        for _ in range(11):  #skip first 11 lines
            next(f)
        for line in f:
            data = (line.split(" "))
            if (len(data) == 5):
                pt = [float(data[1]), float(data[2]), float(data[3])]
                ptsList.append(pt)
                #indxList.append(data[4])
        f.close()
    print(len(ptsList))
Example #4
0
def readSrfs():
    path = rs.WorkingFolder()
    filename = rip.RhinoGet.GetFileName(ric.GetFileNameMode.OpenTextFile, "*",
                                        "select file", None)

    with open(filename, "r") as f:
        for _ in range(1):  #skip first 1 lines
            next(f)
        for line in f:
            dataTMP = (line.split(" "))
            stateList = dataTMP[9].split(",")
            for i in range(6):
                data = dataTMP[12 + 2 * i].split(",")
                indxList = []
                for _data in data:
                    indxList.append(int(_data))
                state = int(stateList[i])
                srfsList.append(node(indxList, state))
        f.close()
    print(len(srfsList))
#Automating A Tower Massing and Exporting it to separate files

import rhinoscriptsyntax as rs
import Rhino

#Load Grasshopper Plugin as gh
gh = Rhino.RhinoApp.GetPlugInObject("Grasshopper")

#SetSliderValue("GUID",Number)
#BakeDateInObject("GUID")

rs.EnableRedraw(True)

#set working directory
workingDir = rs.BrowseForFolder(None, "Pick a foler to save your files in")
rs.WorkingFolder(workingDir)

#create variable for file naming
num = 0

for i in range(1, 3, 1):
    #BaseSize Slider
    gh.SetSliderValue("GUID_FOR_SLIDER_1", i)
    for j in range(0, 4, 1):
        #Rotation Slider
        gh.SetSliderValue("GUID_FOR_SLIDER_2", j)
        for k in range(3, 5, 1):
            #NumberOfSides Slider
            gh.SetSliderValue("GUID_FOR_SLIDER_3", k)
            gh.RunSolver("FILENAME.gh")
            baked = gh.BakeDataInObject("GUID_FOR_BAKE_OBJECT")
Example #6
0
import rhinoscriptsyntax as rs
import Rhino.Input as rip
import Rhino.Input.Custom as ric
#open point file and read
ptsList = []
indxList = []
pt = []
path = rs.WorkingFolder()
filename = rip.RhinoGet.GetFileName(ric.GetFileNameMode.OpenTextFile, "*",
                                    "select file", None)

with open(filename, "r") as f:
    for _ in range(1):  #skip first 1 lines
        next(f)
    for line in f:
        data = (line.split(" "))
        pt = [float(data[1]), float(data[2]), float(data[3])]
        ptsList.append(pt)
        indxList.append(data[4])
    f.close()
print(len(ptsList))

#draw point
for i in range(len(ptsList)):
    pnt = rs.CreatePoint(ptsList[i])
    ptID = rs.AddPoint(pnt)
    rs.AddText(str(indxList[i]), pnt, height=0.2)