コード例 #1
0
    def _inset_floor_surfaces( _floor_surface, _inset_dist, _ghenv ):
        '''Shrinks/Insets the surface by the specified amount '''

        try:
            rh_srfc = from_face3d(_floor_surface.geometry)
        except Exception as e:
            msg = 'Error. Can not convert floor surface: "{}" to Rhino geometry?'.format( _floor_surface )
            _ghenv.Component.AddRuntimeMessage(ghK.GH_RuntimeMessageLevel.Remark, msg)
            return None

        if _inset_dist < 0.001:
            return rh_srfc
        
        #-----------------------------------------------------------------------
        srfcPerim = ghc.JoinCurves( ghc.BrepEdges(rh_srfc)[0], preserve=False )
        
        # Get the inset Curve
        srfcCentroid = Rhino.Geometry.AreaMassProperties.Compute(rh_srfc).Centroid
        plane = ghc.XYPlane(srfcCentroid)
        srfcPerim_Inset_Pos = ghc.OffsetCurve(srfcPerim, _inset_dist, plane, 1)
        srfcPerim_Inset_Neg = ghc.OffsetCurve(srfcPerim, _inset_dist*-1, srfcCentroid, 1)
        
        # Choose the right Offset Curve. The one with the smaller area
        srfcInset_Pos = ghc.BoundarySurfaces( srfcPerim_Inset_Pos )
        srfcInset_Neg = ghc.BoundarySurfaces( srfcPerim_Inset_Neg )
        area_Pos = ghc.Area(srfcInset_Pos).area
        area_neg = ghc.Area(srfcInset_Neg).area
        
        if area_Pos < area_neg:
            return srfcInset_Pos
        else:
            return srfcInset_Neg
コード例 #2
0
 def depth(self):
     '''Used for non-res lighting evaluation. The room depth(m) from the main window wall '''
     
     if self._depth:
         return self._depth
     
     worldXplane = ghc.XYPlane( Rhino.Geometry.Point3d(0,0,0) )
     
     # Find the 'short' edge and the 'long' egde of the srfc geometry
     srfcEdges = ghc.DeconstructBrep(self.surface).edges
     segLengths = ghc.SegmentLengths(srfcEdges).longest_length
     srfcEdges_sorted = ghc.SortList(segLengths, srfcEdges).values_a
     endPoints = ghc.EndPoints(srfcEdges_sorted[-1])
     longEdgeVector = ghc.Vector2Pt(endPoints.start, endPoints.end, False).vector
     shortEdgeVector = ghc.Rotate(longEdgeVector, ghc.Radians(90), worldXplane).geometry
     
     # Use the edges to find the orientation and dimensions of the room
     srfcAligedPlane = ghc.ConstructPlane(ghc.Area(self.surface).centroid, longEdgeVector, shortEdgeVector)
     srfcAlignedWorld = ghc.Orient(self.surface, srfcAligedPlane, worldXplane).geometry
     dims = ghc.BoxProperties( srfcAlignedWorld ).diagonal
     dims = [dims.X, dims.Y]
     width = min(dims)
     depth = max(dims)
     
     return depth
コード例 #3
0
def get_spatial_data(breps):
    """ Creates a dictionary with volume and area of the breps"""
    spatial_data = {"area":[],"volume":[]}
    for i, room_brep in enumerate(breps):
        # Get volume
        room_volume, room_centroid = ghc.Volume(room_brep)
        spatial_data["volume"].append(int(room_volume))
        # Get Area
        room_area = brep_area(room_brep, ghc.XYPlane(room_centroid))
        spatial_data["area"].append(int(room_area))
    return spatial_data
コード例 #4
0
ファイル: windows.py プロジェクト: tejaskumar555/LBT-2-PH
 def _get_vector_from_center_to_edge(_surface, _surface_plane):
     """ Find a Vector from center of surface to mid-point on each edge.
     
     Arguments:
         _surface: The Rhino surface to analyze.
         _surface_plane: A Plane aligned to the surface.
     Returns:
         edgeVectors: (List) Vector3D for mid-point on each edge
     """
     
     worldOrigin = Rhino.Geometry.Point3d(0,0,0)
     worldXYPlane = ghc.XYPlane(worldOrigin)
     geomAtWorldZero = ghc.Orient(_surface, _surface_plane, worldXYPlane).geometry
     edges = ghc.DeconstructBrep(geomAtWorldZero).edges
     
     # Find the mid-point for each edge and create a vector to that midpoint
     crvMidPoints = [ ghc.CurveMiddle(edge) for edge in edges ]
     edgeVectors = [ ghc.Vector2Pt(midPt, worldOrigin, False).vector for midPt in crvMidPoints ]
     
     return edgeVectors
コード例 #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
# 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)):
    # b_zにて低いブリッジの断面方向配置位置を生成, yz_posにて低いブリッジを生成するための基点生成
    b_z = Lo[random.randrange(0, len(Lo))]
コード例 #7
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)