def __init__(self,
              name,
              sorted_points,
              surface_type=None,
              is_name_set_by_user=False,
              is_type_set_by_user=False,
              states=None):
     """Initialize Honeybee Surface."""
     self._childSurfaces = ()
     self._states = []
     if not name:
         name = util.random_name()
         is_name_set_by_user = False
     self.name = (name, is_name_set_by_user)
     """Surface name."""
     self.points = sorted_points
     """A list of points as tuples or lists of (x, y, z).
     Points should be sorted. This class won't sort the points.
     (e.g. ((0, 0, 0), (10, 0, 0), (0, 10, 0)))
     """
     self.surface_type = (surface_type, is_type_set_by_user)
     """Surface type."""
     self.state = 0
     """Current state of the surface."""
     states = states or \
         (SurfaceState('default', SurfaceProperties(self.surface_type)),)
     for state in states:
         self.add_surface_state(state)
示例#2
0
    def from_geometry(cls, name, geometry, is_name_set_by_user=False,
                      rad_properties=None, ep_properties=None, states=None, group=False):
        """Create a honeybee fenestration surface from Grasshopper geometry."""
        assert honeybee.isplus, \
            '"fromGeometries" method can only be used in [+] libraries.'

        name = name or util.random_name()

        if isinstance(name, basestring):
            names = (name,)
        elif not hasattr(name, '__iter__'):
            names = (name,)
        else:
            names = name

        namescount = len(names) - 1

        srf_data = plus.extract_geometry_points(geometry)
        cls._isCreatedFromGeo = True

        if not group:
            hbsrfs = []
            # create a separate surface for each geometry.
            for gcount, srf in enumerate(srf_data):
                for scount, (geo, pts) in enumerate(srf):
                    try:
                        _name = '%s_%d_%d' % (names[gcount], gcount, scount)
                    except IndexError:
                        _name = '%s_%d_%d' % (names[-1], gcount, scount)

                    _srf = cls(_name, pts, is_name_set_by_user, rad_properties,
                               ep_properties, states)
                    _srf.geometry = geo
                    hbsrfs.append(_srf)

            # check naming and fix it if it's only single geometry
            if (gcount == 0 or gcount <= namescount) and scount == 0:
                # this is just a single geometry. remove counter
                for hbsrf in hbsrfs:
                    hbsrf.name = '_'.join(hbsrf.name.split('_')[:-2])
            elif gcount == 0 or gcount == namescount:
                # this is a single geometry with multiple sub surfaces like a polysurface
                for hbs in hbsrfs:
                    bname = hbs.name.split('_')
                    hbs.name = '%s_%s' % ('_'.join(bname[:-2]), bname[-1])
            return hbsrfs
        else:
            _geos = []
            _pts = []
            # collect all the points in a single list
            for srf in srf_data:
                for geo, pts in srf:
                    _pts.extend(pts)
                    _geos.append(geo)

            _srf = cls(names[0], _pts, is_name_set_by_user, rad_properties,
                       ep_properties, states)
            _srf.geometry = _geos
            return _srf
示例#3
0
    def name(self, new_name):
        """Set name and isSetByUser property.

        Args:
            new_name: A name.
        """
        new_name = new_name or util.random_name()
        self._name = str(new_name)
        util.check_name(self._name)
示例#4
0
    def name(self, new_name):
        """Set name and isSetByUser property.

        Args:
            new_name: A name.
        """
        new_name = new_name or util.random_name()
        self._name = str(new_name)
        util.check_name(self._name)
示例#5
0
 def __init__(self, name, sorted_points, surface_type=None, is_name_set_by_user=False,
              is_type_set_by_user=False, states=None):
     """Initialize Honeybee Surface."""
     self._childSurfaces = ()
     self._states = []
     if not name:
         name = util.random_name()
         is_name_set_by_user = False
     self.name = (name, is_name_set_by_user)
     """Surface name."""
     self.points = sorted_points
     """A list of points as tuples or lists of (x, y, z).
     Points should be sorted. This class won't sort the points.
     (e.g. ((0, 0, 0), (10, 0, 0), (0, 10, 0)))
     """
     self.surface_type = (surface_type, is_type_set_by_user)
     """Surface type."""
     self.state = 0
     """Current state of the surface."""
     states = states or \
         (SurfaceState('default', SurfaceProperties(self.surface_type)),)
     for state in states:
         self.add_surface_state(state)