Skip to content

Commit

Permalink
fix(extra): Add option to filter viewport of visualization set legend
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Jun 3, 2024
1 parent 169c6bf commit 35bedc2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
Binary file modified ladybug_grasshopper/icon/LB Preview VisualizationSet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion ladybug_grasshopper/json/LB_Preview_VisualizationSet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.1",
"version": "1.8.2",
"nickname": "VisSet",
"outputs": [
[
Expand Down Expand Up @@ -40,6 +40,13 @@
"description": "Optional text or an integer to select a specific data set from analysis\ngeometries within the Visualization Set. Note that this input only has\nmeaning for Visualization Sets that contain multiple data sets assigned\nto the same geometry. When using an integer, this will refer to the\nindex of the data set to be visualized (starting with 0). When using\ntext, this will refer to the name of the data type for the data set\nto be displayed.",
"type": "string",
"default": null
},
{
"access": "item",
"name": "viewport_",
"description": "Text for the name of the Rhino viewport to which the 2D screen-oriented\nlegend will be rendered. If unspecified, the 2D legend will be rendered\nin all viewports. Acceptable inputs include:\n-\nPerspective\nTop\nBottom\nLeft\nRight\nFront\nBack\nany view name that has been saved within the Rhino file",
"type": "string",
"default": null
}
],
"subcategory": "4 :: Extra",
Expand Down
29 changes: 23 additions & 6 deletions ladybug_grasshopper/src/LB Preview VisualizationSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
index of the data set to be visualized (starting with 0). When using
text, this will refer to the name of the data type for the data set
to be displayed.
viewport_: Text for the name of the Rhino viewport to which the 2D screen-oriented
legend will be rendered. If unspecified, the 2D legend will be rendered
in all viewports. Acceptable inputs include:
-
Perspective
Top
Bottom
Left
Right
Front
Back
any view name that has been saved within the Rhino file
Returns:
vs: A VisualizationSet object that can be baked into the Rhino document by
Expand All @@ -56,11 +68,12 @@ def __init__(self):
super(MyComponent,self).__init__()
self.vis_con = None
self.vs_goo = None
self.viewport = None

def RunScript(self, _vis_set, legend_par_, leg_par2d_, data_set_):
def RunScript(self, _vis_set, legend_par_, leg_par2d_, data_set_, viewport_):
ghenv.Component.Name = 'LB Preview VisualizationSet'
ghenv.Component.NickName = 'VisSet'
ghenv.Component.Message = '1.8.1'
ghenv.Component.Message = '1.8.2'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '1'
Expand Down Expand Up @@ -165,9 +178,11 @@ def RunScript(self, _vis_set, legend_par_, leg_par2d_, data_set_):
geo.active_data = i
self.vis_con = VisualizationSetConverter(vis_set_obj, leg3d, leg2d)
self.vs_goo = VisSetGoo(vis_set_obj)
self.viewport = viewport_
else:
self.vis_con = None
self.vs_goo = None
self.viewport = None

# return the bake-able version of the visualization set
return self.vs_goo
Expand Down Expand Up @@ -209,10 +224,12 @@ def DrawViewportWires(self, args):
display.DrawCone(*draw_args)
for draw_args in self.vis_con.draw_cylinder:
display.DrawCylinder(*draw_args)
for draw_args in self.vis_con.draw_2d_text:
display.Draw2dText(*draw_args)
for draw_args in self.vis_con.draw_sprite:
display.DrawSprite(*draw_args)
if self.viewport is None or \
self.viewport.lower() == args.Viewport.Name.lower():
for draw_args in self.vis_con.draw_2d_text:
display.Draw2dText(*draw_args)
for draw_args in self.vis_con.draw_sprite:
display.DrawSprite(*draw_args)
except Exception, e:
System.Windows.Forms.MessageBox.Show(str(e), "script error")

Expand Down
Binary file modified ladybug_grasshopper/user_objects/LB Preview VisualizationSet.ghuser
Binary file not shown.
Binary file modified samples/visualization_set.gh
Binary file not shown.

0 comments on commit 35bedc2

Please sign in to comment.