Skip to content

Commit

Permalink
fix(extra): Improve the message
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Sep 20, 2023
1 parent 979bdbe commit c587fc7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Binary file modified ladybug_grasshopper/icon/LB Spatial Heatmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ladybug_grasshopper/json/LB_Spatial_Heatmap.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.6.1",
"nickname": "Heatmap",
"outputs": [
[
Expand Down Expand Up @@ -92,7 +92,7 @@
}
],
"subcategory": "4 :: Extra",
"code": "\ntry:\n from ladybug.legend import LegendParameters\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_display.visualization import VisualizationSet\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_mesh3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.color import color_to_color\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\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 # translate to Ladybug objects\n lb_mesh = to_mesh3d(_mesh)\n if offset_dom_:\n dom_st, dom_end = offset_dom_\n lb_mesh = lb_mesh.height_field_mesh(_values, (dom_st, dom_end))\n\n # create the VisualizationSet and GraphicContainer\n if legend_title_ is not None:\n legend_par_ = legend_par_.duplicate() if legend_par_ is not None \\\n else LegendParameters()\n legend_par_.title = legend_title_\n vis_set = VisualizationSet.from_single_analysis_geo(\n 'Data_Mesh', [lb_mesh], _values, legend_par_)\n graphic = vis_set.graphic_container()\n\n # generate titles\n if global_title_ is not None:\n title = text_objects(global_title_, graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # draw {{cad}} objects\n lb_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(lb_mesh)\n legend = legend_objects(graphic.legend)\n colors = [color_to_color(col) for col in lb_mesh.colors]\n legend_par = graphic.legend_parameters\n",
"code": "\ntry:\n from ladybug.legend import LegendParameters\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_display.visualization import VisualizationSet\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug:\\n\\t{}'.format(e))\n\ntry:\n from ladybug_{{cad}}.togeometry import to_mesh3d\n from ladybug_{{cad}}.fromgeometry import from_mesh3d\n from ladybug_{{cad}}.fromobjects import legend_objects\n from ladybug_{{cad}}.text import text_objects\n from ladybug_{{cad}}.color import color_to_color\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs\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 # translate to Ladybug objects\n lb_mesh = to_mesh3d(_mesh)\n if offset_dom_:\n dom_st, dom_end = offset_dom_\n lb_mesh = lb_mesh.height_field_mesh(_values, (dom_st, dom_end))\n\n # check the values against the mesh\n assert len(_values) == len(lb_mesh.faces) or len(_values) == len(lb_mesh.vertices), \\\n 'Expected the number of data set values ({}) to align with the number of faces ' \\\n '({}) or the number of vertices ({}).\\nConsider flattening the _values input ' \\\n 'and using the \"Mesh Join\" component to join the _mesh input.'.format(\n len(_values), len(lb_mesh.faces), len(lb_mesh.vertices))\n\n # create the VisualizationSet and GraphicContainer\n if legend_title_ is not None:\n legend_par_ = legend_par_.duplicate() if legend_par_ is not None \\\n else LegendParameters()\n legend_par_.title = legend_title_\n vis_set = VisualizationSet.from_single_analysis_geo(\n 'Data_Mesh', [lb_mesh], _values, legend_par_)\n graphic = vis_set.graphic_container()\n\n # generate titles\n if global_title_ is not None:\n title = text_objects(global_title_, graphic.lower_title_location,\n graphic.legend_parameters.text_height * 1.5,\n graphic.legend_parameters.font)\n\n # draw {{cad}} objects\n lb_mesh.colors = graphic.value_colors\n mesh = from_mesh3d(lb_mesh)\n legend = legend_objects(graphic.legend)\n colors = [color_to_color(col) for col in lb_mesh.colors]\n legend_par = graphic.legend_parameters\n",
"category": "Ladybug",
"name": "LB Spatial Heatmap",
"description": "Color a mesh as a heatmap using values that align with the mesh faces or vertices.\n_\nNote that any brep can be converted to a gridded mesh that can be consumed by \nthis component using the \"LB Generate Point Grid\" component.\n-"
Expand Down
9 changes: 8 additions & 1 deletion ladybug_grasshopper/src/LB Spatial Heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

ghenv.Component.Name = 'LB Spatial Heatmap'
ghenv.Component.NickName = 'Heatmap'
ghenv.Component.Message = '1.6.0'
ghenv.Component.Message = '1.6.1'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '1'
Expand Down Expand Up @@ -76,6 +76,13 @@
dom_st, dom_end = offset_dom_
lb_mesh = lb_mesh.height_field_mesh(_values, (dom_st, dom_end))

# check the values against the mesh
assert len(_values) == len(lb_mesh.faces) or len(_values) == len(lb_mesh.vertices), \
'Expected the number of data set values ({}) to align with the number of faces ' \
'({}) or the number of vertices ({}).\nConsider flattening the _values input ' \
'and using the "Mesh Join" component to join the _mesh input.'.format(
len(_values), len(lb_mesh.faces), len(lb_mesh.vertices))

# create the VisualizationSet and GraphicContainer
if legend_title_ is not None:
legend_par_ = legend_par_.duplicate() if legend_par_ is not None \
Expand Down
Binary file modified ladybug_grasshopper/user_objects/LB Spatial Heatmap.ghuser
Binary file not shown.

0 comments on commit c587fc7

Please sign in to comment.