-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(csv): Import CSV objects, rebuild windows
- Add Import CSV Component - Add Rebuild Window Surfaces Component - Fixe Phius Site Component
- Loading branch information
Showing
13 changed files
with
395 additions
and
12 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
honeybee_grasshopper_ph/src/HBPH - Create Objects From CSV.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# | ||
# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models | ||
# | ||
# This component is part of the PH-Tools toolkit <https://github.com/PH-Tools>. | ||
# | ||
# Copyright (c) 2022, PH-Tools and bldgtyp, llc <[email protected]> | ||
# Honeybee-PH is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published | ||
# by the Free Software Foundation; either version 3 of the License, | ||
# or (at your option) any later version. | ||
# | ||
# Honeybee-PH is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# For a copy of the GNU General Public License | ||
# see <https://github.com/PH-Tools/honeybee_ph/blob/main/LICENSE>. | ||
# | ||
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> | ||
# | ||
""" | ||
Create a series of new objects based on an arbitrary CSV file input. Note that | ||
the first row in the CSV should be the 'headers' which are used as the attribute | ||
names for the object. Each row in the CSV will become a new object with the | ||
attribute values as defined in the file. | ||
- | ||
EM April 2, 2023 | ||
Args: | ||
_path: (str) The path to the .CSV file to read. | ||
_object_name: (str) Optional name for the class of the new Objects. | ||
_datatypes: (List[str]) Optional list of datatypes to use to cast the | ||
input data values. This list should follow the structure "header: type" | ||
for instance, inputing: | ||
- - - | ||
"Height: float" | ||
"Width: float" | ||
"ID: int" | ||
- - - | ||
will case the "Height" and "Width" attributes to float types, but will cast the | ||
"ID" attribute as an int. | ||
Returns: | ||
objects_: The list of new Objects created from the CSV file. | ||
""" | ||
|
||
import scriptcontext as sc | ||
import Rhino as rh | ||
import rhinoscriptsyntax as rs | ||
import ghpythonlib.components as ghc | ||
import Grasshopper as gh | ||
|
||
from honeybee_ph_rhino import gh_compo_io, gh_io | ||
|
||
# ------------------------------------------------------------------------------ | ||
import honeybee_ph_rhino._component_info_ | ||
reload(honeybee_ph_rhino._component_info_) | ||
ghenv.Component.Name = "HBPH - Create Objects From CSV" | ||
DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev=False) | ||
if DEV: | ||
from honeybee_ph_rhino.gh_compo_io import util_create_objs_from_csv as gh_compo_io | ||
reload(gh_compo_io) | ||
|
||
# ------------------------------------------------------------------------------ | ||
# -- GH Interface | ||
IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) | ||
|
||
# ------------------------------------------------------------------------------ | ||
gh_compo_interface = gh_compo_io.GHCompo_CreateObjectsFromCSV( | ||
IGH, | ||
_path, | ||
_object_name, | ||
_datatypes, | ||
) | ||
objects_ = gh_compo_interface.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
honeybee_grasshopper_ph/src/HBPH - Rebuild Window Surfaces.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Honeybee-PH: A Plugin for adding Passive-House data to LadybugTools Honeybee-Energy Models | ||
# | ||
# This component is part of the PH-Tools toolkit <https://github.com/PH-Tools>. | ||
# | ||
# Copyright (c) 2022, PH-Tools and bldgtyp, llc <[email protected]> | ||
# Honeybee-PH is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published | ||
# by the Free Software Foundation; either version 3 of the License, | ||
# or (at your option) any later version. | ||
# | ||
# Honeybee-PH is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# For a copy of the GNU General Public License | ||
# see <https://github.com/PH-Tools/honeybee_ph/blob/main/LICENSE>. | ||
# | ||
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> | ||
# | ||
""" | ||
Re-build rectangular surface geometry based on a series of input widths and heights. This | ||
is useful when you need to re-draw windows based on a detailed schedule, or other similar | ||
model-wide revisions to geometry. This component will center the new geometry in the same location | ||
as the old geometry. Use Bake (or HumanUI Bake to get names and custom layers) to push this | ||
new geometry back to the Rhino scene. | ||
- | ||
EM April 2, 2023 | ||
Args: | ||
_window_surfaces: (List[Guid]) A list of surface Guids to perform the transformation on. | ||
_widths: (List[float]) A list of the new widths. | ||
_heights: (List[float]) A list of the new heights. | ||
Returns: | ||
new_surfaces_: The new surfaces with the specified width and height values | ||
names_: A list of the names of the new surfaces. | ||
""" | ||
|
||
import scriptcontext as sc | ||
import Rhino as rh | ||
import rhinoscriptsyntax as rs | ||
import ghpythonlib.components as ghc | ||
import Grasshopper as gh | ||
|
||
try: | ||
from honeybee_ph_utils import preview | ||
except ImportError as e: | ||
raise ImportError('Failed to import honeybee_ph_utils:\t{}'.format(e)) | ||
|
||
try: | ||
from honeybee_ph_rhino import gh_compo_io, gh_io | ||
except ImportError as e: | ||
raise ImportError('Failed to import honeybee_ph_rhino:\t{}'.format(e)) | ||
|
||
# ------------------------------------------------------------------------------- | ||
import honeybee_ph_rhino._component_info_ | ||
reload(honeybee_ph_rhino._component_info_) | ||
ghenv.Component.Name = "HBPH - Rebuild Window Surfaces" | ||
DEV = honeybee_ph_rhino._component_info_.set_component_params(ghenv, dev="23402") | ||
if DEV: | ||
reload(gh_io) | ||
from honeybee_ph_rhino.gh_compo_io import win_rebuild_rh_geom as gh_compo_io | ||
reload(gh_compo_io) | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# -- GH Interface | ||
IGH = gh_io.IGH( ghdoc, ghenv, sc, rh, rs, ghc, gh ) | ||
|
||
# ------------------------------------------------------------------------------ | ||
gh_compo_interface = gh_compo_io.GHCompo_RebuildWindowSurfaces( | ||
IGH, _window_surfaces, _widths, _heights | ||
) | ||
new_surfaces_, names_ = gh_compo_interface.run() |
Binary file removed
BIN
-4.76 KB
honeybee_grasshopper_ph/user_objects/HBPH - Create Site From Phius File.ghuser
Binary file not shown.
Binary file added
BIN
+3.84 KB
honeybee_grasshopper_ph/user_objects/HBPH - Create Objects From CSV.ghuser
Binary file not shown.
Binary file added
BIN
+3.65 KB
honeybee_grasshopper_ph/user_objects/HBPH - Create Site From Phius File.ghuser
Binary file not shown.
Binary file added
BIN
+3.56 KB
honeybee_grasshopper_ph/user_objects/HBPH - Rebuild Window Surfaces.ghuser
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.