Ejemplo n.º 1
0
    def _getheight(obj):
        geomlist = [x for n in obj for x in n]
        te = ghc.BrepJoin(geomlist).breps
        sm = ghc.MergeFaces(te).breps
        pt = ghc.Area(sm).centroid

        return pt.Z
Ejemplo n.º 2
0
def buildZoneBrep(_zoneObjs, _opaqueSurfaces):

    # Takes in the IDF Surfaces and builds Zone Breps from them

    # Sets the ZoneObj as an attr using the new Brep

    zoneBreps = []

    for zone in _zoneObjs:

        zoneSurfaces = []

        for srfc in _opaqueSurfaces:

            if srfc.HostZoneName == zone.ZoneName:

                zoneSurfaces.append(ghc.BoundarySurfaces(srfc.Boundary))

        zoneBrep = ghc.BrepJoin(zoneSurfaces).breps

        zoneBreps.append(zoneBrep)

        setattr(zone, 'ZoneBrep', zoneBrep)

    return zoneBreps
Ejemplo n.º 3
0
    def _build_volume_brep_from_geom(self):
        results = ghc.BrepJoin( [self.tfa_surface.surface, self._space_geom.breps] )
        #Un-pack the results
        output = []
        if results:
            for brep, closed in zip(results.breps, results.closed):
                if closed:
                    output.append( brep )

        return output  
Ejemplo n.º 4
0
def get_footprint(_surfaces):
    # Finds the 'footprint' of the building for 'Primary Energy Renewable' reference
    # 1) Re-build the Opaque Surfaces
    # 2) Join all the surface Breps into a single brep
    # 3) Find the 'box' for the single joined brep
    # 4) Find the lowest Z points on the box, offset another 10 units 'down'
    # 5) Make a new Plane at this new location
    # 6) Projects the brep edges onto the new Plane
    # 7) Split a surface using the edges, combine back into a single surface

    Footprint = namedtuple('Footprint',
                           ['Footprint_surface', 'Footprint_area'])

    #----- Build brep
    surfaces = (from_face3d(surface.Srfc) for surface in _surfaces)
    bldg_mass = ghc.BrepJoin(surfaces).breps
    bldg_mass = ghc.BoundaryVolume(bldg_mass)
    if not bldg_mass:
        return Footprint(None, None)

    #------- Find Corners, Find 'bottom' (lowest Z)
    bldg_mass_corners = [v for v in ghc.BoxCorners(bldg_mass)]
    bldg_mass_corners.sort(reverse=False, key=lambda point3D: point3D.Z)
    rect_pts = bldg_mass_corners[0:3]

    #------- Projection Plane
    projection_plane1 = ghc.Plane3Pt(rect_pts[0], rect_pts[1], rect_pts[2])
    projection_plane2 = ghc.Move(projection_plane1, ghc.UnitZ(-10)).geometry
    matrix = rs.XformPlanarProjection(projection_plane2)

    #------- Project Edges onto Projection Plane
    projected_edges = []
    for edge in ghc.DeconstructBrep(bldg_mass).edges:
        projected_edges.append(ghc.Transform(edge, matrix))

    #------- Split the projection surface using the curves
    l1 = ghc.Line(rect_pts[0], rect_pts[1])
    l2 = ghc.Line(rect_pts[0], rect_pts[2])
    max_length = max(ghc.Length(l1), ghc.Length(l2))

    projection_surface = ghc.Polygon(projection_plane2, max_length * 100, 4,
                                     0).polygon
    projected_surfaces = ghc.SurfaceSplit(projection_surface, projected_edges)

    #------- Remove the biggest surface from the set(the background srfc)
    projected_surfaces.sort(key=lambda x: x.GetArea())
    projected_surfaces.pop(-1)

    #------- Join the new srfcs back together into a single one
    unioned_NURB = ghc.RegionUnion(projected_surfaces)
    unioned_surface = ghc.BoundarySurfaces(unioned_NURB)

    return Footprint(unioned_surface, unioned_surface.GetArea())
Ejemplo n.º 5
0
def calcFootprint(_zoneObjs, _opaqueSurfaces):
    # Finds the 'footprint' of the building for 'Primary Energy Renewable' reference
    # 1) Re-build the zone Breps
    # 2) Join all the zone Breps into a single brep
    # 3) Find the 'box' for the single joined brep
    # 4) Find the lowest Z points on the box, offset another 10 units 'down'
    # 5) Make a new Plane at this new location
    # 6) Projects the brep onto the new Plane

    #-----
    zoneBreps = []
    for zone in _zoneObjs:
        zoneSurfaces = []
        for srfc in _opaqueSurfaces:
            if srfc.HostZoneName == zone.ZoneName:
                zoneSurfaces.append(ghc.BoundarySurfaces(srfc.Boundary))
        zoneBrep = ghc.BrepJoin(zoneSurfaces).breps
        zoneBreps.append(zoneBrep)

    bldg_mass = ghc.SolidUnion(zoneBreps)

    if bldg_mass == None:
        return None

    #------- Find Corners, Find 'bottom' (lowest Z)
    bldg_mass_corners = [v for v in ghc.BoxCorners(bldg_mass)]
    bldg_mass_corners.sort(reverse=False, key=lambda point3D: point3D.Z)
    rect_pts = bldg_mass_corners[0:3]

    #------- Project Brep to Footprint
    projection_plane1 = ghc.Plane3Pt(rect_pts[0], rect_pts[1], rect_pts[2])
    projection_plane2 = ghc.Move(projection_plane1, ghc.UnitZ(-10)).geometry
    matrix = rs.XformPlanarProjection(projection_plane2)
    footprint_srfc = rs.TransformObjects(bldg_mass, matrix, copy=True)
    footprint_area = rs.Area(footprint_srfc)

    #------- Output
    Footprint = namedtuple('Footprint',
                           ['Footprint_surface', 'Footprint_area'])
    fp = Footprint(footprint_srfc, footprint_area)

    return fp
Ejemplo n.º 6
0
    # See if you can make a closed room Brep

    # If you can, create a new Room Volume from the closed Brep set

    # Then remove that Room's Geom from the set to test (to speed future search?)

    # If no closables match found, create a default room volume

    # If no room geom input, just build a default size room for each

    if len(roomGeomBreps) > 0:

        for i, roomGeom in enumerate(roomGeomBreps):

            tfaFloorJoinedToGeom = ghc.BrepJoin([roomGeom, tfaSrfcObj.Surface])

            if tfaFloorJoinedToGeom.closed == True:

                newRmVol = PHPP_RoomVolume(tfaSrfcObj, roomGeom)

                roomGeomBreps.pop(i)

                break

        else:

            newRmVol = PHPP_RoomVolume(tfaSrfcObj,
                                       _roomGeom=None,
                                       _roomHeightUD=2.5)
Ejemplo n.º 7
0
 def _getz(obj):
     geomlst = [x for n in obj for x in n]
     te = ghc.BrepJoin(geomlst).breps
     cnt = ghc.Area(te).centroid
     return cnt.Z
Ejemplo n.º 8
0
 def _floorVerts(obj):
     geomslst = [x for n in obj for x in n]
     te = ghc.BrepJoin(geomslst).breps
     sm = ghc.MergeFaces(te).breps
     return _get_verts(sm)
Ejemplo n.º 9
0
import ghpythonlib.components as ghc
import ghpythonlib.parallel as ghp

#divide circle curves into pnts
indivpoints = {}
for circle in circles:
    points = ghc.DivideCurve(circle, splits, False)[0]
    for num in range(0, splits):
        indivpoints.update({num:[points[num]]}) if num not in indivpoints.keys() else indivpoints[num].append(points[num])

#create polylines from points at index between circles
polylines = [ghc.PolyLine(indivpoints[key], False) for key in indivpoints.keys()] 
polylines.append(polylines[0])#to allow a full loop

#create ruled surfaces between polylines
loftsdata = [[polylines[loft],polylines[loft+1]] for loft in range(0, splits)]

#running ruled surfaces in parallel compute
lofts = ghc.CapHoles(ghc.BrepJoin(ghp.run(lambda x: ghc.RuledSurface(x[0], x[1]), loftsdata, True))[0])
    tfa_srfcs_grouped_by_neighbor, ghenv)

# Build the Spaces for each tfa surface
# ------------------------------------------------------------------------------
phpp_spaces_dict = {}
for tfa_srfc in tfa_srfcs_cleaned:
    # See if you can make a closed space Brep
    # If you can, create a new Room Volume from the closed Brep set
    # Then remove that Room's Geom from the set to test (to speed future search?)
    # If no closables match found, create a default space volume
    # If no space geom input, just build a default size space for each

    # --------------------------------------------------------------------------
    if _spaces_geometry:
        for i, space_geometry in enumerate(space_geom):
            joined_vol = ghc.BrepJoin([space_geometry, tfa_srfc.surface])
            if joined_vol.closed is True:
                new_space_vol = LBT2PH.spaces.Volume(tfa_srfc, joined_vol)
                #_spaces_geometry.pop(i) # Causes error sometimes... used to speed things up. Might be another way
                break
        else:
            msg = 'Could not join {} with any space geometry.'.format(
                tfa_srfc.dict_key)
            ghenv.Component.AddRuntimeMessage(
                ghK.GH_RuntimeMessageLevel.Remark, msg)
            new_space_vol = LBT2PH.spaces.Volume(tfa_srfc)
    else:
        new_space_vol = LBT2PH.spaces.Volume(tfa_srfc)

    # --------------------------------------------------------------------------
    # Sort the new Space Volume into the master Dict based on name