Skip to content

Commit 3bf6eef

Browse files
committed
fix(create): Add filters to "Get Grids and Views"
1 parent c604adc commit 3bf6eef

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed
-4 Bytes
Loading

honeybee_grasshopper_radiance/json/HB_Get_Grids_and_Views.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.8.0",
2+
"version": "1.8.1",
33
"nickname": "GetGridsViews",
44
"outputs": [
55
[
@@ -40,10 +40,24 @@
4040
"description": "A Honeybee Model for which grids and views will be output.",
4141
"type": "System.Object",
4242
"default": null
43+
},
44+
{
45+
"access": "item",
46+
"name": "view_filter_",
47+
"description": "Text for a view identifer or a pattern to filter the views of the\nmodel that are output. For instance, `first_floor_*` will simulate\nonly the views that have an identifier that starts with `first_floor_`.\nBy default, all views in the model will be output.",
48+
"type": "string",
49+
"default": null
50+
},
51+
{
52+
"access": "item",
53+
"name": "grid_filter_",
54+
"description": "Text for a grid identifer or a pattern to filter the sensor grids of\nthe model that are output. For instance, first_floor_* will simulate\nonly the sensor grids that have an identifier that starts with\nfirst_floor_. By default, all grids in the model will be output.",
55+
"type": "string",
56+
"default": null
4357
}
4458
],
4559
"subcategory": "0 :: Basic Properties",
46-
"code": "\ntry: # import core ladybug_geometry dependencies\n from ladybug_geometry.geometry3d.pointvector import Point3D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_geometry:\\n\\t{}'.format(e))\n\ntry: # import core honeybee dependencies\n from honeybee.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.fromgeometry import from_point3d, from_mesh3d\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, list_to_data_tree\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component):\n assert isinstance(_model, Model), \\\n 'Expected Honeybee Model. Got {}.'.format(type(_model))\n # get the honeybee-radiance objects\n views = _model.properties.radiance.views\n grids = _model.properties.radiance.sensor_grids\n\n # get the visualizable attributes\n points = [[from_point3d(Point3D.from_array(s.pos)) for s in sg] for sg in grids]\n points = list_to_data_tree(points)\n meshes = []\n for grid in grids:\n if grid.mesh is not None:\n meshes.append(from_mesh3d(grid.mesh))\n",
60+
"code": "\ntry: # import core ladybug_geometry dependencies\n from ladybug_geometry.geometry3d.pointvector import Point3D\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_geometry:\\n\\t{}'.format(e))\n\ntry: # import core honeybee dependencies\n from honeybee.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import honeybee_radiance dependencies\n from honeybee_radiance.writer import _filter_by_pattern\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee_radiance:\\n\\t{}'.format(e))\n\ntry: # import ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.fromgeometry import from_point3d, from_mesh3d\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, list_to_data_tree\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component):\n assert isinstance(_model, Model), \\\n 'Expected Honeybee Model. Got {}.'.format(type(_model))\n # get the honeybee-radiance objects\n views = _model.properties.radiance.views\n if view_filter_ is not None:\n views = _filter_by_pattern(views, view_filter_)\n grids = _model.properties.radiance.sensor_grids\n if grid_filter_ is not None:\n grids = _filter_by_pattern(grids, grid_filter_)\n\n # get the visualizable attributes\n points = [[from_point3d(Point3D.from_array(s.pos)) for s in sg] for sg in grids]\n points = list_to_data_tree(points)\n meshes = []\n for grid in grids:\n if grid.mesh is not None:\n meshes.append(from_mesh3d(grid.mesh))\n",
4761
"category": "HB-Radiance",
4862
"name": "HB Get Grids and Views",
4963
"description": "Get Radiance Sensor Grids and/or Views from a Honeybee Model and visualize them\nin the Rhino scene.\n-"

honeybee_grasshopper_radiance/src/HB Get Grids and Views.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
1515
Args:
1616
_model: A Honeybee Model for which grids and views will be output.
17+
view_filter_: Text for a view identifer or a pattern to filter the views of the
18+
model that are output. For instance, `first_floor_*` will simulate
19+
only the views that have an identifier that starts with `first_floor_`.
20+
By default, all views in the model will be output.
21+
grid_filter_: Text for a grid identifer or a pattern to filter the sensor grids of
22+
the model that are output. For instance, first_floor_* will simulate
23+
only the sensor grids that have an identifier that starts with
24+
first_floor_. By default, all grids in the model will be output.
1725
1826
Returns:
1927
views: A list of Honeybee-Radiance Views that are assigned to the
@@ -27,7 +35,7 @@
2735

2836
ghenv.Component.Name = 'HB Get Grids and Views'
2937
ghenv.Component.NickName = 'GetGridsViews'
30-
ghenv.Component.Message = '1.8.0'
38+
ghenv.Component.Message = '1.8.1'
3139
ghenv.Component.Category = 'HB-Radiance'
3240
ghenv.Component.SubCategory = '0 :: Basic Properties'
3341
ghenv.Component.AdditionalHelpFromDocStrings = '5'
@@ -42,6 +50,11 @@
4250
except ImportError as e:
4351
raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))
4452

53+
try: # import honeybee_radiance dependencies
54+
from honeybee_radiance.writer import _filter_by_pattern
55+
except ImportError as e:
56+
raise ImportError('\nFailed to import honeybee_radiance:\n\t{}'.format(e))
57+
4558
try: # import ladybug_rhino dependencies
4659
from ladybug_rhino.fromgeometry import from_point3d, from_mesh3d
4760
from ladybug_rhino.grasshopper import all_required_inputs, list_to_data_tree
@@ -54,7 +67,11 @@
5467
'Expected Honeybee Model. Got {}.'.format(type(_model))
5568
# get the honeybee-radiance objects
5669
views = _model.properties.radiance.views
70+
if view_filter_ is not None:
71+
views = _filter_by_pattern(views, view_filter_)
5772
grids = _model.properties.radiance.sensor_grids
73+
if grid_filter_ is not None:
74+
grids = _filter_by_pattern(grids, grid_filter_)
5875

5976
# get the visualizable attributes
6077
points = [[from_point3d(Point3D.from_array(s.pos)) for s in sg] for sg in grids]
Binary file not shown.

0 commit comments

Comments
 (0)