예제 #1
0
def standardize_surfaces(srf):
    srf = ghc.ProjectAlong(srf, global_XY, global_Z_neg)[0]
    srf_normal = ghc.EvaluateSurface(srf, ghc.ConstructPoint(0.5, 0.5, 0))[1]
    if srf_normal[2] < 0:
        return ghc.Flip(srf)[0]
    else:
        return srf
예제 #2
0
    def _build_volume_brep_from_zone(self):      
        # Floor Surface
        floor_surface = rs.coercebrep(self.tfa_surface.surface)
        floor_surface = ghc.Move(floor_surface, ghc.UnitZ(self._offset_z) )[0]  # 0 is the new translated geometry

        # Extrusion curve
        surface_centroid = Rhino.Geometry.AreaMassProperties.Compute(floor_surface).Centroid
        end_point = ghc.ConstructPoint(surface_centroid.X, surface_centroid.Y, surface_centroid.Z + self._space_height)
        extrusion_curve = rs.AddLine(surface_centroid, end_point)

        volume_brep = rs.ExtrudeSurface(surface=floor_surface, curve=extrusion_curve, cap=True)
        volume_brep = rs.coercebrep(volume_brep)
        
        return [volume_brep]
예제 #3
0
def getIDFWindowObjects(_IDF_Objs, _windowConstructionsSimple,
                        _windowMaterialsSimple):

    # Finds all  the widnow surfaces and builds window objects

    windowSurfaces = []

    windowObjs_raw = []

    windowObjs_filtered = []

    windowObjs_triangulated = {}

    for eachIDFobj in _IDF_Objs:

        try:

            idfObjName = getattr(eachIDFobj, 'objName')

        except:

            idfObjName = ''

        # If its an EP Window Object

        if 'FenestrationSurface:Detailed' in idfObjName:

            windowObjs_raw.append(eachIDFobj)

    ##################################################

    # Fix for window triangulation

    for windowObj in windowObjs_raw:

        # Honeybee adds the code '..._glzP_0, ..._glzP_1, etc..' suffix to the name for its triangulated windows

        if '_glzP_' in windowObj.Name:

            # See if it has only 3 vertices as well just to double check

            numOfVerts = 0

            for key in windowObj.__dict__.keys():

                if 'XYZ Vertex' in key:

                    numOfVerts += 1

            if numOfVerts == 3:

                # Ok, so its a triangulated window.

                # File the triangulated window in the dictionary using its name as key

                tempWindowName = windowObj.Name.split('_glzP_')[0]

                if tempWindowName not in windowObjs_triangulated.keys():

                    windowObjs_triangulated[tempWindowName] = [windowObj]

                else:

                    windowObjs_triangulated[tempWindowName].append(windowObj)

            else:

                windowObjs_filtered.append(windowObj)

        else:

            windowObjs_filtered.append(windowObj)

    # Unite the triangulated objects

    for key in windowObjs_triangulated.keys():

        perims = []

        for windowObj in windowObjs_triangulated[key]:

            triangleVerts = []

            # Get the verts

            for key in windowObj.__dict__.keys():

                if 'XYZ Vertex' in key:

                    verts = getattr(windowObj, key).split(' ')

                    verts = [float(x) for x in verts]

                    point = ghc.ConstructPoint(verts[0], verts[1], verts[2])

                    triangleVerts.append(point)

            # Union the Segments, find the outside perimeter

            perim = ghc.PolyLine(triangleVerts, closed=True)

            perims.append(perim)

        unionedPerim = ghc.RegionUnion(perims)

        # Build a new Window Obj using this now unioned geometry

        newVertPoints = ghc.ControlPoints(
            unionedPerim).points  #windowObj.__dict__

        newWindowObj = copy.deepcopy(windowObj)

        for i in range(len(newVertPoints)):

            setattr(newWindowObj, 'XYZ Vertex {} {}'.format(i + 1, '{m}'),
                    str(newVertPoints[i]).replace(',', ' '))

            setattr(newWindowObj, 'Name', windowObj.Name[:-7])

        windowObjs_filtered.append(newWindowObj)

    ##################################################

    # Build the Window Objects

    for eachWindowObj in windowObjs_filtered:

        # Find the windows's CONSTRUCTION and MATERIAL information in the IDF

        thisWindowEP_CONST_Name = getattr(
            eachWindowObj,
            'Construction Name')  # Get the name of the Windows' Construction

        thisWindowEP_MAT_Name = _windowConstructionsSimple[
            thisWindowEP_CONST_Name].Layers[0][
                1]  # Find the Material name of 'Layer 1' in the Window's Construction

        thisWindowEP_WinSimp_Obj = _windowMaterialsSimple[
            thisWindowEP_MAT_Name]  # Find the 'WindowMaterial:SimpleGlazingSystem' Object with the same name as 'Layer 1'

        winterShadingFactor = 0.75

        summerShadingFactor = 0.75

        # Create the new IDF_Obj_surfaceWindow Object

        windowSurfaces.append(
            IDF_Obj_surfaceWindow(eachWindowObj, thisWindowEP_WinSimp_Obj,
                                  winterShadingFactor, summerShadingFactor))

    return windowSurfaces
예제 #4
0
B = []

#----------------------------------------------------------------
# 以下xキープリスト,yキープリスト内のブリッジ形態(端部を傾斜)に変更
for i in xkeepList:
    P = []
    P.append(gh.BoxCorners(i)._0)
    P.append(gh.BoxCorners(i)._1)
    P.append(gh.BoxCorners(i)._2)
    P.append(gh.BoxCorners(i)._3)
    P.append(gh.BoxCorners(i)._4)
    P.append(gh.BoxCorners(i)._5)
    P.append(gh.BoxCorners(i)._6)
    P.append(gh.BoxCorners(i)._7)
    t = gh.Distance(P[0], P[4])
    P[0] = gh.ConstructPoint(P[0][0] + t / 4, P[0][1], P[0][2])
    P[1] = gh.ConstructPoint(P[1][0] - t / 4, P[1][1], P[1][2])
    P[2] = gh.ConstructPoint(P[2][0] - t / 4, P[2][1], P[0][2])
    P[3] = gh.ConstructPoint(P[3][0] + t / 4, P[3][1], P[1][2])
    B.append(gh.ConstructMesh((P[0], P[1], P[2], P[3])))
    B.append(gh.ConstructMesh((P[4], P[5], P[6], P[7])))
    B.append(gh.ConstructMesh((P[0], P[3], P[7], P[4])))
    B.append(gh.ConstructMesh((P[1], P[2], P[6], P[5])))
    B.append(gh.ConstructMesh((P[0], P[1], P[5], P[4])))
    B.append(gh.ConstructMesh((P[2], P[3], P[7], P[6])))

for i in ykeepList:
    P = []
    P.append(gh.BoxCorners(i)._0)
    P.append(gh.BoxCorners(i)._1)
    P.append(gh.BoxCorners(i)._2)
예제 #5
0
Returns:
    connectivity [index] - Room connectivity in adjacency graph representation
"""
import rhinoscriptsyntax as rs
import ghpythonlib.components as ghc
import Rhino.Geometry as rg
import ghpythonlib.treehelpers as ght

# Create output List
connectivity = []
P = []
# Define global tool objects
reparam = rg.Interval(0, 1)
global_Z = rg.Vector3d(0, 0, 1)
global_Z_neg = ghc.Reverse(global_Z)
global_XY = ghc.XYPlane(ghc.ConstructPoint(0, 0, 0))


def standardize_surfaces(srf):
    srf = ghc.ProjectAlong(srf, global_XY, global_Z_neg)[0]
    srf_normal = ghc.EvaluateSurface(srf, ghc.ConstructPoint(0.5, 0.5, 0))[1]
    if srf_normal[2] < 0:
        return ghc.Flip(srf)[0]
    else:
        return srf


def create_outside_points(segment):
    # Create a point mid-curve outside the region
    n_pts = max(int(segment.GetLength() / sample), 1)
    curve_points, tangents, _ = ghc.DivideCurve(segment, n_pts, False)
예제 #6
0
                if pair not in b_pos_x:
                    b_pos_x.append(pair)
# x座標が等しいコアの組合せに対して実行(y方向に架かるのブリッジ生成情報の取得)
            if pos[i][0] == pos[ii][0]:
                #wにてコア間の距離を取得, cにてコアとコアの中心位置を取得
                w = gh.Distance(pos[i], pos[ii])
                c = gh.DivideCurve(gh.Line(pos[i], pos[ii]), 2).points[1]
                pair = [c, w]
                if pair not in b_pos_y:
                    b_pos_y.append(pair)

# x方向に架かるブリッジの生成
for i in range(0, len(b_pos_x)):
    #b_zにて低いブリッジの断面方向配置位置を生成, yz_posにて低いブリッジを生成するための基点生成
    b_z = Lo[random.randrange(0, len(Lo))]
    xz_pos = gh.ConstructPoint(b_pos_x[i][0][0], b_pos_x[i][0][1], b_z)
    # 生成された基点にx方向に架かる低いブリッジの生成
    b = gh.CenterBox(gh.XYPlane(xz_pos), b_pos_x[i][1] / 2 + b_width / 2,
                     b_depth / 2, b_hight[0] / 2)
    bridge_x.append(b)
for i in range(0, len(b_pos_x)):
    #b_zにて高いブリッジの断面方向配置位置を生成, yz_posにて低いブリッジを生成するための基点生成
    b_z = Hi[random.randrange(0, len(Hi))]
    # 生成された基点にx方向に架かる高いブリッジの生成
    xz_pos = gh.ConstructPoint(b_pos_x[i][0][0], b_pos_x[i][0][1], b_z)
    b = gh.CenterBox(gh.XYPlane(xz_pos), b_pos_x[i][1] / 2 + b_width / 2,
                     b_depth / 2, b_hight[1] / 2)
    bridge_x.append(b)

# y方向に架かるブリッジの生成
for i in range(0, len(b_pos_y)):
예제 #7
0
            ey = yBank[0] - layerThickness
            ey2 = yBank[-1] + layerThickness
            yBank.append(ex)
            yBank.append(ex2)
            yBank.sort()

    #print "yrange", ycomp,"finalybank", yBank

    "Matriz de puntos"
    #print "lenx", len(xBank)
    if len(xBank) > 0:
        #print "leny", len(yBank)
        if len(yBank) > 0:
            #print "lenz", len(zBank)
            if len(zBank) > 0:
                for co in xBank:
                    for coo in yBank:
                        for coor in zBank:
                            tag = str(co) + ' X ' + str(coo) + ' Y ' + str(
                                coor) + ' Z '
                            if tag not in tagList:
                                tagList.append(tag)
                                poi = gh.ConstructPoint(co, coo, coor)
                                pointList.append(poi)

                                #print zBank, tag

    i += 1

    #print " line ", i
예제 #8
0
import ghpythonlib.components as gh  # 内部モジュールghpythonlib.componentsをghという名前で読み込む
import random  # 内部モジュールrandomを読み込む

ArrayPoint = []  # 生成された配置位置を格納
pos = []  # 選択された配置位置を格納
core = []  # 生成されたコアを格納

# 4行5列のコア配置位置の生成
for i in range(0, 5):
    for ii in range(0, 4):
        p = gh.ConstructPoint(i * span, ii * span, 0)
        ArrayPoint.append(p)

# core_num(得たいコアの本数)となるまで配置位置を無作為に選択してコアを生成
while len(pos) < core_num:
    id = random.randrange(0, len(ArrayPoint))
    if id not in pos:
        pos.append(ArrayPoint[id])
        cpos_z = gh.ConstructPoint(ArrayPoint[id][0], ArrayPoint[id][
                                   1], ArrayPoint[id][2] + 268990 / 2)
        core.append(gh.CenterBox(cpos_z, core_width /
                                 2, core_width / 2, core_hight / 2))
예제 #9
0
# Version: 1.0.0
# Maintainer: Matt Gordon
# Email: [email protected]
# Status: development
##################################################

import math
import random

import rhinoscriptsyntax as rs
import ghpythonlib.components as gh

# === GLOBAL VARIABLES ===

# World Geometry
world_xy = gh.XYPlane(gh.ConstructPoint(0, 0, 0))
world_xz = gh.XZPlane(gh.ConstructPoint(0, 0, 0))
world_yz = gh.YZPlane(gh.ConstructPoint(0, 0, 0))

world_planes = [world_xy, world_xz, world_yz]

# World Sizes
slice_size = grid_size * grid_size
vlength = slice_size * grid_size

max_dist = 6928

# Deltas in Voxel Space: (+z, +y, +x, -y, -x, -z)
dxv = (0, 0, 1, 0, -1, 0)
dyv = (0, 1, 0, -1, 0, 0)
dzv = (1, 0, 0, 0, 0, -1)