示例#1
0
def main():
  """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
  outie = fp.make_out(fp.outies.Rhino, "component")
  outie.set_color(Color.RGB(0.75,0.5,1.0))
  
  # get user input
  innie = fp.make_in(fp.innies.Rhino)
  mymesh = innie.get_mesh()
  pathPrefix = "solarIncidence/"
  path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
  epwdata = epwData(path)
  
  # go through each mesh face, and calcuate the average surface irradiance
  # and store value in irrArr
  irrArr = []
  for i in range(len(mymesh.faces)):
    facePlane = Ray(mymesh.face_centroid(i),mymesh.face_normal(i))
    irrArr.append(avgIrradinaceForYear(facePlane,epwdata))
  
  # go through each mesh face, and construct a component for each face
  for i in range(len(mymesh.faces)):
    height = irrArr[i] / 30
    if height < 1.0 : height = 1.0
    outie.put(pyramidComponent(mymesh,i,height))
  
  outie.draw()
示例#2
0
def main():
    """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
    outie = fp.make_out(fp.outies.Rhino, "component")
    outie.set_color(Color.RGB(0.75, 0.5, 1.0))

    # get user input
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()
    pathPrefix = "solarIncidence/"
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)

    # go through each mesh face, and calcuate the average surface irradiance
    # and store value in irrArr
    irrArr = []
    for i in range(len(mymesh.faces)):
        facePlane = Ray(mymesh.face_centroid(i), mymesh.face_normal(i))
        irrArr.append(avgIrradinaceForYear(facePlane, epwdata))

    # go through each mesh face, and construct a component for each face
    for i in range(len(mymesh.faces)):
        height = irrArr[i] / 30
        if height < 1.0: height = 1.0
        outie.put(pyramidComponent(mymesh, i, height))

    outie.draw()
示例#3
0
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input #
    pathPrefix = ""
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # find the normals for each mesh face
    normals = [
        Ray(mymesh.face_centroid(i), mymesh.face_normal(i))
        for i in range(len(mymesh.faces))
    ]

    # setup our visualization
    colorA = Color.HSB(
        0.75)  #saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(
        0.0)  #saturation and brightness of HSB colors default to 1.0

    # Calculate the Yearly Average or Yearly Maximum Incident Radiation
    # and Visualize Results
    for normal in normals:
        irrArr = []
        for h in range(8760):
            irrArr.append(srfIrradiance(normal, h, epwdata))
        avgIrr = (sum(irrArr)) / (len(irrArr)
                                  )  #Calculates Yearly Average Radiation
        maxIrr = max(irrArr)  #Calculates Yearly Maximum Radiation
        #print '{} Yearly Average Radiation w/m2'.format(avgIrr)

        #visualize results
        normalizedVal = maxIrr / 1000  #sets a range of 0w/m2 -> 1000w/m2
        color = Color.interpolate(colorA, colorB, normalizedVal)
        normal.set_color(color)
        normal.vec.length = normalizedVal * 10

    outie.put([normals])
    outie.draw()
示例#4
0
def main():
    """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
    outie = fp.make_out(fp.outies.Rhino, "component")
    outie.set_color(Color.RGB(0.75, 0.5, 1.0))

    # get user input
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # go through each mesh face, and construct a component for each face
    for i in range(len(mymesh.faces)):
        outie.put(pyramidComponent(mymesh, i, 2))

    outie.draw()
示例#5
0
def main():
  """a simple example of a "component" tiling of a mesh surface.  
  given a mesh with only quad faces, we will generate a simple pyramid-like 
  component to take the place of each mesh face.
  """
  outie = fp.make_out(fp.outies.Rhino, "component")
  outie.set_color(Color.RGB(0.75,0.5,1.0))
  
  # get user input
  innie = fp.make_in(fp.innies.Rhino)
  mymesh = innie.get_mesh()
  
  # go through each mesh face, and construct a component for each face
  for i in range(len(mymesh.faces)):
    outie.put(pyramidComponent(mymesh,i,2))
  
  outie.draw()
示例#6
0
def main():
  """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
  outie = fp.make_out(fp.outies.Rhino, "solar incidence")
  outie.set_color(Color(0.75))
  
  # getting user input #
  pathPrefix = ""
  path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
  epwdata = epwData(path)
  innie = fp.make_in(fp.innies.Rhino)
  mymesh = innie.get_mesh()
  
  # find the normals for each mesh face
  normals = [Ray(mymesh.face_centroid(i),mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
  
  # setup our visualization
  colorA = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0
  colorB = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0
  
  # Calculate the Yearly Average or Yearly Maximum Incident Radiation
  # and Visualize Results
  for normal in normals:
    irrArr = []
    for h in range(8760): irrArr.append(srfIrradiance(normal,h,epwdata))
    avgIrr = (sum(irrArr))/(len(irrArr)) #Calculates Yearly Average Radiation
    maxIrr = max(irrArr) #Calculates Yearly Maximum Radiation
    #print '{} Yearly Average Radiation w/m2'.format(avgIrr)

    #visualize results
    normalizedVal = maxIrr/1000 #sets a range of 0w/m2 -> 1000w/m2
    color = Color.interpolate(colorA,colorB,normalizedVal)
    normal.set_color(color)
    normal.vec.length = normalizedVal * 10
    
  outie.put([normals])
  outie.draw()
示例#7
0
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input
    pathPrefix = ""
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # find the normals for each mesh face
    normals = [
        Ray(mymesh.face_centroid(i), mymesh.face_normal(i))
        for i in range(len(mymesh.faces))
    ]
    meshNormal = [(mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
    meshCentroid = [(mymesh.face_centroid(i))
                    for i in range(len(mymesh.faces))]
    #meshVerts = [(mymesh.face_verts(i)) for i in range(len(mymesh.faces))]
    #print meshVerts

    for normal in meshNormal:
        #midPt = []
        for centroid in meshCentroid:
            #midPt.append(centroid + normal)
            p0 = centroid + normal
    print p0

    #for i in range(len(mymesh.faces)):
    #meshCentroid = mymesh.face_centroid(i)
    #for i in range(len(mymesh.faces)):
    #meshNormal = mymesh.face_normal(i)
    #p0 = meshCentroid + meshNormal

    for i in range(len(mymesh.faces)):
        meshVerts = mymesh.face_verts(i)
    meshPts = meshVerts[:]
    #print meshPts
    meshPts[0:0] = [p0]
    #print meshPts

    m1 = [meshPts[0], meshPts[1], meshPts[2]]
    m2 = [meshPts[0], meshPts[2], meshPts[3]]
    m3 = [meshPts[0], meshPts[3], meshPts[4]]
    m4 = [meshPts[0], meshPts[1], meshPts[4]]

    meshModule = [(Mesh(m1, (0, 1, 2))), (Mesh(m2, (0, 2, 3))),
                  (Mesh(m3, (0, 3, 4))), (Mesh(m4, (0, 1, 4)))]
    print meshModule

    #for n in meshCentroid:
    #print n
    #for i in range(len(mymesh.faces)):
    #meshVerts = mymesh.face_verts(i)
    #for vert in meshVerts:
    #pLine = Line(vert, n)
    #print vert
    #pirLine = Line(vert, n)
    #print pLine
    #p1 = Point(normals)
    #print p1

    #####Rhinoscript
    #mesh = rs.GetObject('Select Mesh')
    #verts, norms, centroid = rs.MeshVertices(mesh), rs.MeshFaceNormals(mesh), rs.MeshFaceCenters(mesh)
    #print norms
    #for norm in norms:
    #for v in verts:
    #for c in norms:
    #rs.AddLine(v, c)

    # setup our visualization
    colorA = Color.HSB(
        0.75)  #saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(
        0.0)  #saturation and brightness of HSB colors default to 1.0

    # Calculate the Yearly Average or Yearly Maximum Incident Radiation
    # and Visualize Results
    for normal in normals:
        irrArr = []
        for h in range(48):
            irrArr.append(srfIrradiance(normal, h, epwdata))
        avgIrr = (sum(irrArr)) / (len(irrArr)
                                  )  #Calculates Yearly Average Radiation
        print '{} Yearly Average Radiation w/m2'.format(avgIrr)

        #visualize results
        normalizedVal = avgIrr / 1000  #sets a range of 0w/m2 -> 1000w/m2
        color = Color.interpolate(colorA, colorB, normalizedVal)
        normal.set_color(color)
        normal.vec.length = normalizedVal * 10

    outie.put([
        normals,
        p0,
    ])
    outie.draw()
示例#8
0
def main():
    """a simple example of calculating solar incident radiation.  
  given a user-defined plane to evaluate, a hard-coded position, 
  and a EPW file that associates date/time with radiation level, 
  calculates the amount of radition striking the plane
  and produces a simple visualization.
  """
    outie = fp.make_out(fp.outies.Rhino, "solar incidence")
    outie.set_color(Color(0.75))

    # getting user input
    pathPrefix = ""
    path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"
    epwdata = epwData(path)
    innie = fp.make_in(fp.innies.Rhino)
    mymesh = innie.get_mesh()

    # find the normals for each mesh face
    normals = [Ray(mymesh.face_centroid(i), mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
    meshNormal = [(mymesh.face_normal(i)) for i in range(len(mymesh.faces))]
    meshCentroid = [(mymesh.face_centroid(i)) for i in range(len(mymesh.faces))]
    # meshVerts = [(mymesh.face_verts(i)) for i in range(len(mymesh.faces))]
    # print meshVerts

    for normal in meshNormal:
        # midPt = []
        for centroid in meshCentroid:
            # midPt.append(centroid + normal)
            p0 = centroid + normal
    print p0

    # for i in range(len(mymesh.faces)):
    # meshCentroid = mymesh.face_centroid(i)
    # for i in range(len(mymesh.faces)):
    # meshNormal = mymesh.face_normal(i)
    # p0 = meshCentroid + meshNormal

    for i in range(len(mymesh.faces)):
        meshVerts = mymesh.face_verts(i)
    meshPts = meshVerts[:]
    # print meshPts
    meshPts[0:0] = [p0]
    # print meshPts

    m1 = [meshPts[0], meshPts[1], meshPts[2]]
    m2 = [meshPts[0], meshPts[2], meshPts[3]]
    m3 = [meshPts[0], meshPts[3], meshPts[4]]
    m4 = [meshPts[0], meshPts[1], meshPts[4]]

    meshModule = [(Mesh(m1, (0, 1, 2))), (Mesh(m2, (0, 2, 3))), (Mesh(m3, (0, 3, 4))), (Mesh(m4, (0, 1, 4)))]
    print meshModule

    # for n in meshCentroid:
    # print n
    # for i in range(len(mymesh.faces)):
    # meshVerts = mymesh.face_verts(i)
    # for vert in meshVerts:
    # pLine = Line(vert, n)
    # print vert
    # pirLine = Line(vert, n)
    # print pLine
    # p1 = Point(normals)
    # print p1

    #####Rhinoscript
    # mesh = rs.GetObject('Select Mesh')
    # verts, norms, centroid = rs.MeshVertices(mesh), rs.MeshFaceNormals(mesh), rs.MeshFaceCenters(mesh)
    # print norms
    # for norm in norms:
    # for v in verts:
    # for c in norms:
    # rs.AddLine(v, c)

    # setup our visualization
    colorA = Color.HSB(0.75)  # saturation and brightness of HSB colors default to 1.0
    colorB = Color.HSB(0.0)  # saturation and brightness of HSB colors default to 1.0

    # Calculate the Yearly Average or Yearly Maximum Incident Radiation
    # and Visualize Results
    for normal in normals:
        irrArr = []
        for h in range(48):
            irrArr.append(srfIrradiance(normal, h, epwdata))
        avgIrr = (sum(irrArr)) / (len(irrArr))  # Calculates Yearly Average Radiation
        print "{} Yearly Average Radiation w/m2".format(avgIrr)

        # visualize results
        normalizedVal = avgIrr / 1000  # sets a range of 0w/m2 -> 1000w/m2
        color = Color.interpolate(colorA, colorB, normalizedVal)
        normal.set_color(color)
        normal.vec.length = normalizedVal * 10

    outie.put([normals, p0])
    outie.draw()