ladybug_rhino.viewport module

Functions for getting viewport properties, creating new viewports, and editing them.

ladybug_rhino.viewport.camera_oriented_plane(origin)[source]

Get a Rhino Plane that is oriented facing the camera.

Parameters:

origin – A Rhino Point for the origin of the plane.

ladybug_rhino.viewport.capture_view(viewport, file_path, width=None, height=None, display_mode=None, transparent=False)[source]

Capture a Viewport to a PNG file path.

Parameters:
  • viewport – A Rhino ViewPort object, which will have its display mode set.

  • file_path – Full path to the file where the image will be saved.

  • width – Integer for the image width in pixels. If None, the width of the active viewport will be used. (Default: None).

  • height – Integer for the image height in pixels. If None, the height of the active viewport will be used. (Default: None).

  • display_mode – Text for the display mode to which the Rhino viewport will be set. For example: Wireframe, Shaded, Rendered, etc. If None, it will be the current viewport’s display mode. (Default: None).

  • transparent – Boolean to note whether the background of the image should be transparent or have the same color as the Rhino scene. (Default: False).

Returns:

Full path to the image file that was written.

ladybug_rhino.viewport.open_viewport(view_name, width=None, height=None)[source]

Create a new Viewport in the active Rhino document at specified dimensions.

This will also set the newly-created view to be tha active Viewport.

Parameters:
  • view_name – Text for the name of the new Rhino Viewport that will be created.

  • width – Optional positive integer for the width of the view in pixels. If None, the width of the currently active viewport will be used.

  • height – Optional positive integer for the height of the view in pixels. If None, the height of the currently active viewport will be used.

ladybug_rhino.viewport.orient_to_camera(geometry, position=None)[source]

Orient an array of Rhino geometry objects to the camera of the active viewport.

Parameters:
  • geometry – An array of Rhino Geometry objects (or TextGoo objects) to the camera of the active Rhino viewport.

  • position – A point to be used as the origin around which the the geometry will be oriented. If None, the lower left corner of the bounding box around the geometry will be used.

ladybug_rhino.viewport.set_iso_view_direction(viewport, direction, center_point=None)[source]

Set a Rhino Viewport to have an isometric view in a specific direction.

Parameters:
  • viewport – A Rhino ViewPort object, which will have its direction set.

  • direction – A Rhino vector that will be used to set the direction of the isometric view.

  • center_point – Optional Rhino point for the target of the camera. If no point is provided, the Rhino origin will be used (0, 0, 0).

ladybug_rhino.viewport.set_view_direction(viewport, direction, position=None, lens_length=None)[source]

Set a Rhino Viewport to face a specific direction.

Parameters:
  • viewport – A Rhino ViewPort object, which will have its direction set.

  • direction – A Rhino vector that will be used to set the direction of the view.

  • position – Optional Rhino point for the target of the camera. If no point is provided, the Rhino origin will be used (0, 0, 0).

ladybug_rhino.viewport.set_view_display_mode(viewport, display_mode)[source]

Set the display mode of a Rhino Viewport.

Parameters:
  • viewport – A Rhino ViewPort object, which will have its display mode set.

  • display_mode – Text for the display mode to which the Rhino viewport will be set. For example: Wireframe, Shaded, Rendered, etc.

ladybug_rhino.viewport.viewport_by_name(view_name=None)[source]

Get a Rhino Viewport object using the name of the viewport.

Parameters:

view_name – Text for the name of the Rhino Viewport. If None, the current Rhino viewport will be used. If the view is a named view that is not currently open, it will be restored to the active view of the Rhino document.

ladybug_rhino.viewport.viewport_properties(viewport, view_type=None)[source]

Get a dictionary of properties of a Rhino viewport.

Parameters:
  • viewport – A Rhino ViewPort object for which properties will be extracted.

  • view_type

    An integer to set the view type (-vt). Choose from the choices below or set to None to have it derived from the viewport.

    • 0 Perspective (v)

    • 1 Hemispherical fisheye (h)

    • 2 Parallel (l)

    • 3 Cylindrical panorama (c)

    • 4 Angular fisheye (a)

    • 5 Planisphere [stereographic] projection (s)

Returns:

‘view_type’, ‘position’, ‘direction’, ‘up_vector’, ‘h_angle’, ‘v_angle’

Return type:

A dictionary with the following keys

ladybug_rhino.viewport.viewport_vh_vv(viewport, view_type)[source]

Get the horizontal angle (vh) and the vertical angle (vv) from a viewport.

Parameters:
  • viewport – A Rhino ViewPort object for which properties will be extracted.

  • view_type

    An integer to set the view type (-vt). Choose from the choices below.

    • 0 Perspective (v)

    • 1 Hemispherical fisheye (h)

    • 2 Parallel (l)

    • 3 Cylindrical panorama (c)

    • 4 Angular fisheye (a)

    • 5 Planisphere [stereographic] projection (s)