ladybug_display.visualization module

class ladybug_display.visualization.VisualizationSet(identifier, geometry, units=None)[source]

Bases: _VisualizationBase

A visualization set containing analysis and context geometry to be visualized.

Parameters:
  • identifier – Text string for a unique object ID. Must be less than 100 characters and not contain spaces or special characters.

  • geometry – A list of AnalysisGeometry and ContextGeometry objects to display in the visualization. Each geometry object will typically be translated to its own layer within the interface that renders the VisualizationSet.

  • units

    Text for the units system in which the visualization geometry exists. If None, the geometry will always be assumed to be in the current units system of the display interface. (Default: None). Choose from the following:

    • Meters

    • Millimeters

    • Feet

    • Inches

    • Centimeters

Properties:
  • identifier

  • display_name

  • geometry

  • min_point

  • max_point

  • min_point_with_legend

  • max_point_with_legend

  • units

  • user_data

ToString()[source]

Overwrite .NET ToString.

add_geometry(geometry, insert_index=None)[source]

Add a ContextGeometry or AnalysisGeometry object to this VisualizationSet.

Parameters:
  • geometry – A ContextGeometry or AnalysisGeometry object to be added to this VisualizationSet.

  • insert_index – An integer for the index at which the data should be inserted. If None, the data will be appended to the end. (Default: None).

add_vis_set(vis_set)[source]

Add all geometry objects of another VisualizationSet to this one.

Parameters:

vis_set – A VisualizationData object to be added to this AnalysisGeometry.

check_duplicate_identifiers(raise_exception=True, detailed=False)[source]

Check that there are no duplicate geometry object identifiers in the set.

Parameters:
  • raise_exception – Boolean to note whether a ValueError should be raised if duplicate identifiers are found. (Default: True).

  • detailed – Boolean for whether the returned object is a detailed list of dicts with error info or a string with a message. (Default: False).

Returns:

A string with the message or a list with a dictionary if detailed is True.

convert_to_units(units)[source]

Convert all of the geometry in this VisualizationSet to certain units.

This involves scaling the geometry and changing the VisualizationSet’s units property.

Parameters:

units

Text for the units to which the VisualizationSet geometry should be converted. Choose from the following:

  • Meters

  • Millimeters

  • Feet

  • Inches

  • Centimeters

duplicate()

Get a copy of this object.

classmethod from_dict(data)[source]

Create an VisualizationSet from a dictionary.

Parameters:

data – A python dictionary in the following format

{
"type": "VisualizationSet",
"identifier": "",  # unique object identifier
"geometry": []  # list of AnalysisGeometry and ContextGeometry objects
}
classmethod from_file(vis_set_file)[source]

Initialize a VisualizationSet from a JSON or pkl file, auto-sensing the type.

Parameters:

VisualizationSet – Path to either a VisualizationSet JSON or pkl file.

classmethod from_json(json_file)[source]

Initialize a VisualizationSet from a JSON file.

Parameters:

json_file – Path to VisualizationSet JSON file.

classmethod from_pkl(pkl_file)[source]

Initialize a Model from a pkl file.

Parameters:

pkl_file – Path to pkl file.

classmethod from_single_analysis_geo(identifier, geometry, values, legend_parameters=None, data_type=None, unit=None)[source]

Create an VisualizationSet from a raw geometry object and a list of values.

Parameters:
  • identifier – Text string for a unique object ID. Must be less than 100 characters and not contain spaces or special characters.

  • geometry – A list of ladybug-geometry objects that is aligned with the values. The length of this list should usually be equal to the total number of values in each data_set, indicating that each geometry gets a single color. Alternatively, if all of the geometry objects are meshes, the number of values in the data can be equal to the total number of faces across the meshes or the total number of vertices across the meshes.

  • values – A list of numerical values that will be used to generate the visualization colors.

  • legend_parameters – An Optional LegendParameters object to override default parameters of the legend. None indicates that default legend parameters will be used. (Default: None).

  • data_type – Optional DataType from the ladybug datatype subpackage (ie. Temperature()) , which will be used to assign default legend properties. If None, the legend associated with this object will contain no units unless a unit below is specified. (Default: None).

  • unit – Optional text string for the units of the values. (ie. “C”). If None or empty, the default units of the data_type will be used. If no data type is specified in this case, this will simply be an empty string. (Default: None).

graphic_container(geo_index=0, data_index=None, min_point=None, max_point=None)[source]

Get a Ladybug GraphicContainer object, which can be used to draw legends.

Parameters:
  • geo_index – Integer for the index of the geometry for which a GraphicContainer will be returned. Note that this index must refer to an analysis geometry in order to produce a valid graphic container. (Default: 0).

  • data_index – Integer for the index of the data set for which a GraphicContainer will be returned. If None, the active_data set will be used. (Default: None).

  • min_point – An optional Point3D to denote the minimum bounding box for the graphic container. If None, this object’s own min_point will be used, which corresponds to the bounding box around the geometry. (Default: None).

  • max_point – An optional Point3D to denote the maximum bounding box for the graphic container. If None, this object’s own max_point will be used, which corresponds to the bounding box around the geometry. (Default: None).

move(moving_vec)[source]

Move this VisualizationSet along a vector.

Parameters:

moving_vec – A ladybug_geometry Vector3D with the direction and distance to move the VisualizationSet.

remove_geometry(geo_index)[source]

Remove a geometry object from this VisualizationSet.

Parameters:

geo_index – An integer for the geometry index to be removed.

rotate_xy(angle, origin)[source]

Rotate this VisualizationSet counterclockwise in the world XY plane.

Parameters:
  • angle – An angle in degrees.

  • origin – A ladybug_geometry Point3D for the origin around which the object will be rotated.

scale(factor, origin=None)[source]

Scale this VisualizationSet by a factor from an origin point.

Parameters:
  • factor – A number representing how much the object should be scaled.

  • origin – A ladybug_geometry Point3D representing the origin from which to scale. If None, it will be scaled from the World origin (0, 0, 0).

to_dict()[source]

Get VisualizationSet as a dictionary.

to_json(name, folder, indent=None)[source]

Write VisualizationSet to JSON.

Parameters:
  • name – A text string for the name of the JSON file.

  • folder – A text string for the directory where the JSON will be written.

  • indent – A positive integer to set the indentation used in the resulting JSON file. (Default: None).

to_pkl(name, folder)[source]

Write VisualizationSet to compressed pickle file (pkl).

Parameters:
  • name – A text string for the name of the pickle file.

  • folder – A text string for the directory where the pickle file will be written.

to_svg(width=800, height=600, margin=None, interactive=False, render_3d_legend=False, render_2d_legend=False, view='Top')[source]

Get this VisualizationSet as an editable SVG object.

Casting the SVG object to string will give the file contents of a SVG.

All contents of the VisualizationSet will automatically scaled to fit within the specified pixel width and height of the SVG

Parameters:
  • width – The screen width in pixels. (Default: 800).

  • height – The screen height in pixels. (Default: 600).

  • margin – An optional number to set the size of the margins around the base graphic in the final image. If None, this is automatically set to be 2% of whatever the constraining dimension is (either width or height). (Default: None).

  • interactive – A boolean to note whether AnalysisGeometry in the VisualizationSet should be rendered with interactive hover effects (True) or they should be rendered as static (False). If hover effects are included, then objects that are a part of AnalysisGeometries will be highlighted with a thick black border when hovered over and hover text will appear with the value associated with the geometry. (Default: False).

  • render_3d_legend – Boolean to note whether a 3D version of the legend for any AnalysisGeometry should be included in the SVG (following the 3D dimensions specified in the LegendParameters).

  • render_2d_legend – Boolean to note whether a 2D version of the legend for any AnalysisGeometry should be included in the SVG (following the 2D dimensions specified in the LegendParameters).

  • view

    An optional text string for the view for which the SVG will be generated. This can also be a ladybug-geometry Plane object for the plane in which an axonometric view will be generated. Choose from the common options below when using a text string.

    • Top

    • Left

    • Right

    • Front

    • Back

    • NE

    • NW

    • SE

    • SW

ANALYSIS_CLASSES = (<class 'ladybug_display.analysis.AnalysisGeometry'>, <class 'ladybug_display.analysis.VisualizationData'>, <class 'ladybug_display.analysis.VisualizationMetaData'>)
DISPLAY_UNION = (<class 'ladybug_display.geometry2d.vector.DisplayVector2D'>, <class 'ladybug_display.geometry2d.point.DisplayPoint2D'>, <class 'ladybug_display.geometry2d.ray.DisplayRay2D'>, <class 'ladybug_display.geometry2d.line.DisplayLineSegment2D'>, <class 'ladybug_display.geometry2d.polyline.DisplayPolyline2D'>, <class 'ladybug_display.geometry2d.arc.DisplayArc2D'>, <class 'ladybug_display.geometry2d.polygon.DisplayPolygon2D'>, <class 'ladybug_display.geometry2d.mesh.DisplayMesh2D'>, <class 'ladybug_display.geometry3d.vector.DisplayVector3D'>, <class 'ladybug_display.geometry3d.point.DisplayPoint3D'>, <class 'ladybug_display.geometry3d.ray.DisplayRay3D'>, <class 'ladybug_display.geometry3d.plane.DisplayPlane'>, <class 'ladybug_display.geometry3d.line.DisplayLineSegment3D'>, <class 'ladybug_display.geometry3d.polyline.DisplayPolyline3D'>, <class 'ladybug_display.geometry3d.arc.DisplayArc3D'>, <class 'ladybug_display.geometry3d.face.DisplayFace3D'>, <class 'ladybug_display.geometry3d.mesh.DisplayMesh3D'>, <class 'ladybug_display.geometry3d.polyface.DisplayPolyface3D'>, <class 'ladybug_display.geometry3d.sphere.DisplaySphere'>, <class 'ladybug_display.geometry3d.cone.DisplayCone'>, <class 'ladybug_display.geometry3d.cylinder.DisplayCylinder'>, <class 'ladybug_display.geometry3d.text.DisplayText3D'>)
GEOMETRY_UNION = (<class 'ladybug_geometry.geometry2d.pointvector.Vector2D'>, <class 'ladybug_geometry.geometry2d.pointvector.Point2D'>, <class 'ladybug_geometry.geometry2d.ray.Ray2D'>, <class 'ladybug_geometry.geometry2d.line.LineSegment2D'>, <class 'ladybug_geometry.geometry2d.polyline.Polyline2D'>, <class 'ladybug_geometry.geometry2d.arc.Arc2D'>, <class 'ladybug_geometry.geometry2d.polygon.Polygon2D'>, <class 'ladybug_geometry.geometry2d.mesh.Mesh2D'>, <class 'ladybug_geometry.geometry3d.pointvector.Vector3D'>, <class 'ladybug_geometry.geometry3d.pointvector.Point3D'>, <class 'ladybug_geometry.geometry3d.ray.Ray3D'>, <class 'ladybug_geometry.geometry3d.plane.Plane'>, <class 'ladybug_geometry.geometry3d.line.LineSegment3D'>, <class 'ladybug_geometry.geometry3d.polyline.Polyline3D'>, <class 'ladybug_geometry.geometry3d.arc.Arc3D'>, <class 'ladybug_geometry.geometry3d.face.Face3D'>, <class 'ladybug_geometry.geometry3d.mesh.Mesh3D'>, <class 'ladybug_geometry.geometry3d.polyface.Polyface3D'>, <class 'ladybug_geometry.geometry3d.sphere.Sphere'>, <class 'ladybug_geometry.geometry3d.cone.Cone'>, <class 'ladybug_geometry.geometry3d.cylinder.Cylinder'>)
UNITS = ('Meters', 'Millimeters', 'Feet', 'Inches', 'Centimeters')
VIEW_MAP = {'Back': Plane (<0.00, -1.00, 0.00> normal) (<0.00, 0.00, 0.00> origin), 'Front': Plane (<0.00, 1.00, 0.00> normal) (<0.00, 0.00, 0.00> origin), 'Left': Plane (<1.00, 0.00, 0.00> normal) (<0.00, 0.00, 0.00> origin), 'NE': Plane (<0.58, 0.58, 0.58> normal) (<0.00, 0.00, 0.00> origin), 'NW': Plane (<-0.58, 0.58, 0.58> normal) (<0.00, 0.00, 0.00> origin), 'Right': Plane (<-1.00, 0.00, 0.00> normal) (<0.00, 0.00, 0.00> origin), 'SE': Plane (<0.58, -0.58, 0.58> normal) (<0.00, 0.00, 0.00> origin), 'SW': Plane (<-0.58, -0.58, 0.58> normal) (<0.00, 0.00, 0.00> origin), 'Top': Plane (<0.00, 0.00, 1.00> normal) (<0.00, 0.00, 0.00> origin)}
property display_name

Get or set text for the object name without any character restrictions.

This is typically used to set the layer of the object in the interface that renders the VisualizationSet. A :: in the display_name can be used to denote sub-layers following a convention of ParentLayer::SubLayer.

If not set, the display_name will be equal to the object identifier.

property full_id

Get a string with both the object display_name and identifier.

This is formatted as display_name[identifier].

This is useful in error messages to give users an easy means of finding invalid objects within models. If there is no display_name assigned, only the identifier will be returned.

property geometry

Get or set a tuple of AnalysisGeometry and ContextGeometry objects.

property identifier

Get or set a text string for the unique object identifier.

This identifier remains constant as the object is mutated, copied, and serialized to different formats.

property max_point

A Point3D for the maximum bounding box vertex around all of the geometry.

property max_point_with_legend

A Point3D for the maximum around all geometry, including 3D legends.

property min_point

A Point3D for the minimum bounding box vertex around all of the geometry.

property min_point_with_legend

A Point3D for the minimum around all geometry, including 3D legends.

property units

Get or set Text for the units system in which the geometry exists.

property user_data

Get or set an optional dictionary for additional meta data for this object.

This will be None until it has been set. All keys and values of this dictionary should be of a standard Python type to ensure correct serialization of the object to/from JSON (eg. str, float, int, list, dict)