learning rhino python

today i tried several options,

in the first as code below i first read the csv then i make the rectangle on the given sensor value point.

i was success first then again it cannot show the rectangle when i tried.

** i solve the problem for this one in this morning. i forget to close the file after opening , the changes is also in below.

import Rhino
import Rhino.Geometry as rg
import scriptcontext as sc
import System.Drawing
import rhinoscriptsyntax as rs
import csv

def readFile():
    f = open('05 28.csv', 'r')
    rd = csv.reader(f)
    ptlist = []
    slist1 = []
    slist2 = []
    slist3 = []
    slist4 = []
    for line in rd:
        x=float(line[0])
        y=float(line[1])
        z=float(line[2])
        sensor1 = float(line[4])
        sensor2 = float(line[5]*1000)
        sensor3 = float(line[6]*10000)
        sensor4 = float(line[15]*10000)
        pt = (x,y,z-165000)
        s1 = (x,y,z+(sensor1*10000))
        s2 = (x,y,z+sensor2)
        s3 = (x,y,z+sensor3)
        s4 = (x,y,z+sensor4)
        ptlist.append(pt)
        slist1.append(s1)
        slist2.append(s2)
        slist3.append(s3)
        slist4.append(s4)
        return rd * this should be removed
    f.close() * the correct one

    print(ptlist)
    sensor1 = rs.AddPointCloud(slist1) 

    for point in slist1:
        x = 10000
        y = 10000
        point1 = ((point[0]-x/2), (point[1]-y/2), point[2])
        rs.AddRectangle(point1, x,y)
        return slist1
    
          


if __name__=="__main__":

    #AddMaterial()
    #MakeMaterial()
    readFile()

then i decide to try using the box, i thought i can extrude the rectangle in z direction to make a box, which i find impossible. i did as teach in various sources in internet, but when i try to make the box it shows this error.

the code is following

import Rhino
import rhinoscriptsyntax as rs
x = 652356
y = 1236540
z = 167550
l = 10000
b = 10000
h = 500
pt1 = (x-0.5*l, y-0.5*b, z)
pt2 = (x-0.5*l, y+0.5*b, z)
pt3 = (x+0.5*l, y+0.5*b, z)
pt4 = (x+0.5*l, y-0.5*b, z)
pt5 = (x-0.5*l, y-0.5*b, z+h)
pt6 = (x-0.5*l, y+0.5*b, z+h)
pt7 = (x+0.5*l, y+0.5*b, z+h)
pt8 = ((x+0.5*l, y-0.5*b, z+h)
rs.AddBox([pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8])

as i planned this will create a box at the point, but couldn’t do.

Published by Dibash Adhikari

I am a qualified architect and urban planner actively engaged in research exploring the areas of digital fabrication, virtual reality, and smart city development.

Leave a comment

Design a site like this with WordPress.com
Get started